Lazarus Query转EXCEL功能
Lazarus Query转EXCEL功能
需要用到控件XMLXSDExporter1
procedure SaveToExcel(AQuery:TSQLQuery);
var
SaveDialog: TSaveDialog;
Ext:String;
begin
SaveDialog := TSaveDialog.Create(nil);
SaveDialog.Filter:='Excel 97-2003文件(*.xls)|*.XLS';
if SaveDialog.Execute and (trim(SaveDialog.FileName)<>'') then
begin
Ext := 'xls';
if UpperCase(Copy(SaveDialog.FileName,Length(SaveDialog.FileName)-2,3)) <> UpperCase(Ext) then
SaveDialog.FileName := SaveDialog.FileName + '.' + Ext;
if FileExists(SaveDialog.FileName) then
begin
if application.MessageBox('文件名已存在,是否覆盖? ', '提示', MB_ICONASTERISK or MB_OKCANCEL)<>idok then
exit;
end;
XMLXSDExporter1.Dataset := AQuery;
XMLXSDExporter1.FileName := SaveDialog.FileName;
XMLXSDExporter1.Execute;
MessageBox( 0,'导出成功 ', '提示', MB_OK + MB_ICONINFORMATION)
end;
SaveDialog.Destroy;
end;
原文地址:https://blog.csdn.net/lqzmax/article/details/142980897
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!