procedure TForm1.Button1Click(Sender: TObject);
var
myexcel:variant;
workbooklevariant;
worksheetlevariant;
i,j:integer;
begin
try
myexcel:=createoleobject('excel.application');
myexcel.application.workbooks.add;
myexcel.caption:='将数据导入到EXCEL表中';
myexcel.application.visible:=true;
workbook:=myexcel.application.workbooks[1];
worksheet:=workbook.worksheets.item[1];
except
showmessage('EXCEL不存在!');
end;
i:=0;
table1.first;
while not table1.eof do
begin
inc(i);
for j:=0 to table1.fieldcount-1 do
worksheet.cells[i,j+1]:=table1.fields[j].asstring;
table1.next;
end;
end;