说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

怎样使用Delphi 5中的TExcelApplication操纵Excel 97/2000

HTML文档下载 WORD文档下载 PDF文档下载
怎样使用Delphi 5中的TExcelApplication操纵Excel 97/2000

请参考下面的例子

ExcelApplication1.Connect;

ExcelApplication1.Visible[0]:=True;

ExcelApplication1.Workbooks.Add(NULL

0);

ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);

ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Sheets[1] as _WorkSheet);

for idx:=1 to 30 do begin

ExcelWorksheet1.Cells.Item[idx

1]:='Hello '+IntToStr(idx);

ExcelWorksheet1.Cells.Item[idx

2]:= idx;

end;

ExcelWorksheet1.Cells.Item[31

2]:='=SUM(B1:B30)';

ShowMessage('Total is '+ExcelWorksheet1.Cells.Item[31

2]);

ExcelApplication1.Disconnect;

ExcelApplication1.Quit;

备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘