delphi XLSReadWriteII5使用示例  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi XLSReadWriteII5使用示例


procedure TForm1.Button1Click(Sender: TObject);

var

  i, n: Integer;

  XLS: TXLSReadWriteII5; // 引用XLSReadWriteII5, Xc12DataStyleSheet5, ShellAPI

begin

  XLS := TXLSReadWriteII5.Create(nil);

  try

    XLS.Clear;

    XLS.FileName := ExtractFilePath(paramstr(0)) + 'temp.xls';

    for i := 0 to 9 do

      XLS.Sheets[0].AsString[i, 0] := '标题' + IntToStr(i + 1);

    for i := 0 to 9 do

      for n := 1 to 19 do

        XLS.Sheets[0].AsString[i, n] := IntToStr(i + 1) + ':' + IntToStr(n);


    for i := 0 to 9 do // XLS.Sheets[0].LastCol do // 从第一列到最后一列

    begin

      for n := 0 to 19 do // 从第一行到最后一行

      begin

        XLS.Sheets[0].Range.Items[i, n, i, n].BorderOutlineStyle := cbsThin;

        XLS.Sheets[0].Range.Items[i, n, i, n].BorderOutlineColor := 0; // 黑色#0

        if n = 0 then

        begin

          XLS.Sheets[0].Cell[i, n].CellColorRGB := 16744448; // 橘黄#FF8000

          XLS.Sheets[0].Cell[i, n].FontColor := 16777215; // 白色#FFFFFF

        end

        else

          XLS.Sheets[0].Cell[i, n].CellColorRGB := 16777165; // 杏仁灰#FFFFCD

      end;

      XLS.Sheets[0].AutoWidthCol(i); // 每列为自动宽度

    end;

    XLS.Write;

    ShellExecute(0, 'Open', PChar(ExtractFilePath(paramstr(0)) + 'temp.xls') , nil, nil, SW_SHOW);

  finally

    XLS.Free;

  end;

end;


148825-20180327134926103-534225387.png


来源:https://www.offeu.com/www/index_id_144.html


推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.11938500404358 seconds