【发布时间】:2013-05-14 13:28:03
【问题描述】:
我正在尝试将数据从 delphi 7 中的 stringgrid 导出到 microsoft excel。我一直在使用这段代码来做到这一点:
objExcel := TExcelApplication.Create(nil);
objExcel.Visible[LOCALE_USER_DEFAULT] := true;
objWB := objExcel.workbooks.add(null,LOCALE_USER_DEFAULT);
lineNumber := 1;
for i:=1 to stringgrid1.rowcount-1 do begin
for j:=0 to stringgrid1.ColCount-1 do begin
objWB.Worksheets.Application.Cells.Item[i+lineNumber,j+1] := ''''+stringgrid1.Cells[j,i];
end;
end;
但是当数据很大时,需要很长时间才能完成。还有其他更快的方法可以将数据从 delphi 7 stringgrid 导出到 excel 吗?
【问题讨论】:
-
感谢您的快速响应,伙计们。我认为数组方法最适合我现在的情况,因为我不打算使用 .csv 文件。如何将此问题标记为“已解决”?
标签: delphi export-to-excel stringgrid