W
wenwen_pan
Unregistered / Unconfirmed
GUEST, unregistred user!
var
Eclapp,workbook:variant;
i,n:integer;
begin
if not adoquery4.Active then exit;
if adoquery4.RecordCount<=0 then exit;
if application.MessageBox('确认导出excel表吗?','提示',mb_okcancel+mb_iconinformation)=idcancel then
exit;
Eclapp:=createoleobject('Excel.Application');
Eclapp.workbooks.add;
for i:=0 to DBGrid1.FieldCount-1 do
begin
Eclapp.cells[1,i+1]:=DBGrid1.Columns.Title.Caption;
end;
adoquery4.First;
n:=2;
while not adoquery4.Eof do
begin
eclapp.cells[n,1] := adoquery4.Fields[0].AsString;
eclapp.cells[n,2] := adoquery4.Fields[1].AsString;
inc;
adoquery4.Next;
end;
eclapp.cells[n,1] := '满足条件记录的总数为:'+inttostr(adoquery4.RecordCount)+'条';
application.MessageBox('数据导出完成!','提示',mb_ok+mb_iconinformation);
eclapp.visible := true;
end;
为什么"Eclapp:=createoleobject('Excel.Application');"会出现"missing operator or semicolon;"的错误
请大家帮帮忙,谢谢
Eclapp,workbook:variant;
i,n:integer;
begin
if not adoquery4.Active then exit;
if adoquery4.RecordCount<=0 then exit;
if application.MessageBox('确认导出excel表吗?','提示',mb_okcancel+mb_iconinformation)=idcancel then
exit;
Eclapp:=createoleobject('Excel.Application');
Eclapp.workbooks.add;
for i:=0 to DBGrid1.FieldCount-1 do
begin
Eclapp.cells[1,i+1]:=DBGrid1.Columns.Title.Caption;
end;
adoquery4.First;
n:=2;
while not adoquery4.Eof do
begin
eclapp.cells[n,1] := adoquery4.Fields[0].AsString;
eclapp.cells[n,2] := adoquery4.Fields[1].AsString;
inc;
adoquery4.Next;
end;
eclapp.cells[n,1] := '满足条件记录的总数为:'+inttostr(adoquery4.RecordCount)+'条';
application.MessageBox('数据导出完成!','提示',mb_ok+mb_iconinformation);
eclapp.visible := true;
end;
为什么"Eclapp:=createoleobject('Excel.Application');"会出现"missing operator or semicolon;"的错误
请大家帮帮忙,谢谢