//检查EXCEL是否已安装
try
ExcelApplication1.Connect ;
except
showmessage('EXCEL 没有安装');
exit;
end;
if lbcx.savedialog1.execute then
begin
//开始数据导出过程
ExcelApplication1.Workbooks.Add(EmptyParam,0);
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.WorkSheets[1] as _Worksheet);
qkts.ADOquery1.First;
ExcelWorksheet1.Cells.Item[1,1]:='发货人';
ExcelWorksheet1.Cells.Item[1,2]:='收入';
ExcelWorksheet1.Cells.Item[1,3]:='支出';
ExcelWorksheet1.Cells.Item[1,4]:='金额';
for i:=2 to qkts.ADOquery1.recordcount+1 do
begin
for j:=1 to qkts.ADOquery1.fields.count do
ExcelWorksheet1.Cells.Item[i,j]:=qkts.ADOquery1.Fields[j-1].asstring;
qkts.ADOquery1.Next;
end;
ExcelWorksheet1.SaveAs(lbcx.savedialog1.filename+'.xls');
showmessage('导出完成');
end;//if