相关疑难解决方法(0)

将delphi stringgrid导出为ex​​cel

我正在尝试将数据从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;
Run Code Online (Sandbox Code Playgroud)

但是当数据很大时,需要很长时间才能完成.有没有其他更快的方法将数据从delphi 7 stringgrid导出到excel?

delphi export-to-excel stringgrid

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

delphi ×1

export-to-excel ×1

stringgrid ×1