eDocEngine VCL
Create documents and reports in 18 formats
Compatibility
Delphi C++Builder

Export From Quickreport To PDF And Other Formats

Interactive and programmatic export from Quickreport using Gnostice eDocEngine VCL.
By V. Subhash

eDocEngine has "report-export interface components" for providing multiple output format support for Delphi reporting tools. For Quickreport, eDocEngine has the TgtQRExportInterface interface component.

You can either let the end-user of the Quickreport application to choose the output provided by eDocEngine in an interactive report "Save" dialog box or you could export the report programmatically in Object Pascal.

On an application built with Quickreport, an instance of this interface component needs to be paired up with an eDocEngine document-creation engine component. For example, to output a Quickreport report to a PDF document, a TgtQRExportInterface instance needs to be paired with a TgtPDFEngine instance on the same form as a Quickreport report component.

Interactive Quickreport Report Export

  1. Open your IDE and create a new VCL Forms Application project.
  2. Drop the following components on the form.
    • TButton
    • TADODataSet
    • TQRPQuickrep
    • TgtExcelEngine
    • TgtPDFEngine
    • TgtQRExportInterface (2 numbers)
  3. Select the TButton and set its Caption property to "Launch Report".
  4. Select the TADODataSet control and set the following properties
    • ConnectionString - Use the wizard to connect to an ADO datasource such as a Microsoft Access database. (I have used the NorthWind database that ships with MS Access.)
    • CommandText - Enter a valid SQL query that returns some records from the database. (I have used select FirstName, LastName, Address, City, Region, Country from Employees.)
    • Active - Set to true
  5. Select the TQRPQuickrep control and set the following properties.
    • DataSet: Set to the TADODataSet control.
    • Bands » HasDetail: Set to True.
    • Units: Set to MM.
    • Page » Papersize: Set to Custom.
    • Page » Length: Set to 100 mm.
    • Page » Width: Set to 160 mm.
  6. Click on the Detail band of the report and drop a TQRDBText on to it.
  7. Set its DataSet property to the TADODataSet control.
  8. Set its DataField property to one of the fields returned by the SQL query.
  9. Set its font properties if required.
  10. Drop more TQRDBText controls on the form and set them to other fields retrieved by the SQL query. Rearrange them appropriately.
  11. Select the TADODataSet control and ensure that its Active property is still set to true.
  12. Select a TgtQRExportInterface control and set its Engine property to the TgtExcelEngine control.
  13. Select the other TgtQRExportInterface control and set its Engine property to TgtPDFEngine.
  14. Double-click the TButton control and use the following click-event handler.
    QRPQuickrep1.Preview;
    
  15. Run the application.
  16. Click the Launch Report button on the window to show the report preview.
  17. Click the Save report button.
  18. From the Save as type list, select one of the output formats supported by eDocEngine.
  19. In the File name box, enter a file name for the exported report.

Programmatic Quickreport Export

You can make eDocEngine run the report and export the output using a TgtQRExportInterface.RenderDocument() overload.

  1. Add a TgtPDFEngine, a TgtExcelEngine, and two TgtQRExportInterface components to a form with a fully set-up TQRPQuickrep component.
  2. Add a button and set the following click-event handler.
    procedure TForm9.Button3Click(Sender: TObject);
    begin
      // Export report to a PDF document
      gtPDFEngine1.FileName := 'eDoc_Quickreport_Demo.pdf';
      gtPDFEngine1.Preferences.ShowSetupDialog := false;
      gtQRExportInterface1.Engine := gtPDFEngine1;
      gtQRExportInterface1.RenderDocument(QRPQuickrep1, false);
    
      // Export report to a Excel workbook
      gtExcelEngine1.FileName := 'eDoc_Quickreport_Demo.xls';
      gtExcelEngine1.Preferences.ShowSetupDialog := false;
      gtQRExportInterface2.Engine := gtExcelEngine1;
      gtQRExportInterface2.RenderDocument(QRPQuickrep1, false);
    end;
    

Programmatic Quickreport Export Using QRP File

You can also export a report from a QRP file. There is another TgtQRExportInterface.RenderDocument() overload for this.

  1. Add a TgtPDFEngine, a TgtExcelEngine, and a TgtQRExportInterface component to a form that has a TQRPQuickrep component.
  2. Add a button and then add this click-event handler for it.
    procedure TForm9.Button2Click(Sender: TObject);
    begin
      gtPDFEngine1.FileName := 'eDoc_QuickReport_Demo.pdf';
      gtPDFEngine1.Preferences.ShowSetupDialog := false;
      gtQRExportInterface1.Engine := gtPDFEngine1;
      gtQRExportInterface1.RenderDocument('eDoc_QuickReport.QRP');
    end;
    

---o0O0o---

Our .NET Developer Tools
XtremeDocumentStudio .NET

Multi-format document-processing component suite for .NET developers.

PDFOne .NET

A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

Our Delphi/C++Builder developer tools
XtremeDocumentStudio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our Java developer tools
XtremeDocumentStudio (for Java)

Multi-format document-processing component suite for Java developers.

PDFOne (for Java)

A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications.

Our Platform-Agnostic Cloud and On-Premises APIs
StarDocs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2016 Gnostice Information Technologies Private Limited. All rights reserved.