01]在自带备选控件里,要手动安装

02]以TSQLExporter,导出为SQL的Insert语句

03]TCSVExporter,导出为CSV格式

04]SimpleJSONExporter1,导出为JSON格式

05]RTF楼上类似,写字板打开正常,但WPS文字打开没有数据

06]导出类似EXCEL2007的标签形式的文件XMLXSDExporter1

参考:https://blog.csdn.net/bq_cui/article/details/134248119     


01]在自带备选控件里,要手动安装

 控件名:lazdbexport1.0

 安装成功后,即可看到导出控件。

TCSVExporter,
TFixedLengthExporter,
TSQLExporter,
TXMLXSDExporter,
TSimpleXMLExporter,
TSimpleJSONExporter,
TFPDBFExport,
TTexExporter,
TRTFExporter,
TStandardExportFormats,
TFPDataExporter

=============================================================================================

02]以TSQLExporter,为例:假设SQLQuery1已正确连接,能显示数据

procedure TForm1.Button5Click(Sender: TObject);
//var
//  fnOut: string;
begin
  //SaveDialog1.Filter := 'sql文件|*.sql';
  //if SaveDialog1.Execute then       fnOut := SaveDialog1.FileName
  //
  //else                                exit;
  SQLExporter1.Dataset := SQLQuery1;
  SQLExporter1.FormatSettings.TableName := 'userinfo';
  SQLExporter1.FileName := 'D:\aaa.sql'; // fnOut;  //连SaveDialog1省略的话
  SQLExporter1.Execute;
end; 

不仅TableName 还有更多导出格式修改选项参数可以调整

 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 03]TCSVExporter,为CSV:假设SQLQuery1已正确连接,能显示数据

procedure TForm1.Button6Click(Sender: TObject);
begin
CSVExporter1.Dataset := SQLQuery1;
CSVExporter1.FileName := 'D:\bbb.csv';
CSVExporter1.Execute;
end;   

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 04]SimpleJSONExporter1,为例:假设SQLQuery1已正确连接,能显示数据

procedure TForm1.Button7Click(Sender: TObject);
begin
 SimpleJSONExporter1.Dataset := SQLQuery1;
 SimpleJSONExporter1.FileName := 'D:\ccc.json';
 SimpleJSONExporter1.Execute;
end;  

 05]RTF楼上类似,写字板打开正常,但WPS文字打开没有数据,Word2007也打不开

procedure TForm1.Button7Click(Sender: TObject);
begin
 RTFExporter1.Dataset := SQLQuery1;
 RTFExporter1.FileName := 'D:\ccc.rtf';
 RTFExporter1.Execute;
end;

 06]导出类似EXCEL2007的标签形式的文件XMLXSDExporter1

procedure TForm1.Button7Click(Sender: TObject);
begin
 XMLXSDExporter1.Dataset := SQLQuery1;
 XMLXSDExporter1.FileName := 'D:\xxx.xls';
 XMLXSDExporter1.Execute;
end; 

WPS能直接打开

 

 

但保存时,提示要 另存为xlsx

 

 

Excel2007