H
huanq
Unregistered / Unconfirmed
GUEST, unregistred user!
有一个paradox的表,有6千多条记录,想创建一个excel,并将标的内容导入该excel文件
请问怎么才能最快,而且代码简单
我用的代码如下,可速度不行
var eclapp,workbook:variant;
try
eclapp:=createoleobject('excel.application');
workbook:=createoleobject('excel.sheet');
workbook:=eclapp.workbooks.add;
eclapp.cells(1,5):='明细表';
eclapp.cells(2,7):='导出时间:'+ formatdatetime('yyyy-mm-dd hh:nn',now);
except
Messagebox(0,'该系统可能未正确安装Microsoft Excel!','系统错误!',MB_ok);
exit;
end;
query1.First;
for i:=0 to query1.FieldCount-1 do
begin
eclapp.cells(3,i+1):=query1.Fields.FieldName;
end;
for i:=0 to query1.RecordCount-1 do
begin
eclapp.cells(i+4,1):=formatdatetime('yyyy-mm-dd hh:nn:ss',query1.fieldbyname('时间').AsDateTime);
for j:=1 to query1.FieldCount-1 do
begin
eclapp.cells(i+4,j+1):=format('%8.4f',[query1.Fields[j].AsFloat]);
end;
query1.Next;
end;
eclapp.visible:=true;
eclapp:=unassigned;
请问怎么才能最快,而且代码简单
我用的代码如下,可速度不行
var eclapp,workbook:variant;
try
eclapp:=createoleobject('excel.application');
workbook:=createoleobject('excel.sheet');
workbook:=eclapp.workbooks.add;
eclapp.cells(1,5):='明细表';
eclapp.cells(2,7):='导出时间:'+ formatdatetime('yyyy-mm-dd hh:nn',now);
except
Messagebox(0,'该系统可能未正确安装Microsoft Excel!','系统错误!',MB_ok);
exit;
end;
query1.First;
for i:=0 to query1.FieldCount-1 do
begin
eclapp.cells(3,i+1):=query1.Fields.FieldName;
end;
for i:=0 to query1.RecordCount-1 do
begin
eclapp.cells(i+4,1):=formatdatetime('yyyy-mm-dd hh:nn:ss',query1.fieldbyname('时间').AsDateTime);
for j:=1 to query1.FieldCount-1 do
begin
eclapp.cells(i+4,j+1):=format('%8.4f',[query1.Fields[j].AsFloat]);
end;
query1.Next;
end;
eclapp.visible:=true;
eclapp:=unassigned;