Jump to content

[Solved] Export uniDBGrid to Excel, Word, CSV or HTML


Recommended Posts

uses JvDBGridExport, DBGrids;  // Activex; for Word/Excel

   mygrid : TDBGrid;
   myexport : TJvDBGridCSVExport;
    //   myexport : TJvDBGridExcelExport;
    //   myexport : TJvDBGridWordExport;
    //   myexport : TJvDBGridHTMLExport;

      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;
      // read exceptions in: myexport.LastExceptionMessage;


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.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...