itognet Posted June 8, 2017 Share Posted June 8, 2017 uses JvDBGridExport, DBGrids; // Activex; for Word/Excel var mygrid : TDBGrid; myexport : TJvDBGridCSVExport; // myexport : TJvDBGridExcelExport; // myexport : TJvDBGridWordExport; // myexport : TJvDBGridHTMLExport; begin mygrid := TDBGrid.Create(nil); mygrid.DataSource := unimainmodule.myexportdatasource; // CoInitialize(nil); // call only if export to Word/Excel myexport := TJvDBGridCSVExport.Create(nil); // myexport := TJvDBGridExcelExport.Create(nil); // myexport := TJvDBGridWordExport.Create(nil); // myexport := TJvDBGridHTMLExport.Create(nil); myexport.FileName := 'c:\myexport.csv'; myexport.ExportSeparator := esSemiColon; // estab, esComma, esSemiColon myexport.Grid := mygrid; myexport.ExportGrid; // read exceptions in: myexport.LastExceptionMessage; myexport.Free; mygrid.Free; end; If you want to export to Word/Excel, then you have to have Office installed on the Server. Excel can easily read CSV files. You need to have JVCL in your Delphi. 1 Quote Link to comment Share on other sites More sharing options...
itognet Posted June 8, 2017 Author Share Posted June 8, 2017 If using Word/Excel export use: CoInitialize(nil); try CoInitialize(nil); try //Do some ADO work finally CoUninitialize; end; finally CoUninitialize; end; Quote Link to comment Share on other sites More sharing options...
fcarvalho4 Posted June 8, 2017 Share Posted June 8, 2017 Great! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.