Report Export
- 6 minutes to read
The Report Generator for Delphi and C++Builder (the TdxReport component) allows you to export generated documents to a format of your choice: DOCX, PDF, XLSX, CSV, RTF, etc.

Report Export APIs
This section lists all export methods declared in the TdxReport class.
Tip
Refer to individual method descriptions for detailed information and code examples.
Document Export Methods
- ExportToDOCX(TStream) | ExportToDOCX(String)
- Export the current report to a file or stream in the Office OpenXML Document (DOCX) format.
- ExportToHTML(TStream) | ExportToHTML(String)
- Export the current report to a file or stream in the HyperText Markup Language (HTML) format.
- ExportToMHT(TStream) | ExportToMHT(String)
- Export the current report to a file or stream in the MIME HTML (MHT) format.
- ExportToPDF(TStream) | ExportToPDF(String)
- Export the current report to a file or stream in the Portable Document Format (PDF).
- ExportToRTF(TStream) | ExportToRTF(String)
- Export the current report to a file or stream in the Rich Text Format (RTF).
- ExportToText(TStream) | ExportToText(String)
- Export the current report to a file or stream as plain text.
Image Export Methods
- ExportToImage(TStream) | ExportToImage(String)
- Export the current report to a file or stream as an image.
Target Image Format and Export Settings
The default image export format is Portable Network Graphics (PNG).
You can select any supported image format and configure its settings in the Report Designer dialog (Behavior | Export Options):

Spreadsheet Export Methods
- ExportToCSV(TStream) | ExportToCSV(String)
- Export the current report to a file or stream in the comma-separated values (CSV) format.
- ExportToXLS(TStream) | ExportToXLS(String)
- Export the current report to a file or stream in the Microsoft Excel® binary (XLS) format.
- ExportToXLSX(TStream) | ExportToXLSX(String)
- Export the current report to a file or stream in the Office OpenXML Spreadsheet (XLSX) format.
Universal Export Methods
- ExportTo(TdxReportExportFormat,TStream) | ExportTo(TdxReportExportFormat,TStream,string) | ExportTo(TdxReportExportFormat,string)
- Export the current report to a file or stream in any supported format.
End-User Report Export Functionality
Users can export reports using the built-in drop-down menu within the Report Viewer dialog:

Export Settings
The Report Designer dialog allows users to configure export settings for all supported formats. Open the Properties tab and expand the following nodes to modify PDF export settings: Behavior | Export Options.

Export-Related Event
A click on any item in the export drop-down menu raises the OnExport event.
You can handle this event to execute custom code in response to a report export operation, modify the export target, replace the built-in Save As dialog, or prevent the operation depending on specific conditions in your application.
Note
Report export methods never raise the OnExport event.
Code Examples
Export Report Content to PDF File
The following code example configures a memory-based data source (TdxBackendInMemoryJSONConnection), loads an XML-based (REPX) report layout, and exports generated report (TdxReport) content to a file in the PDF format:
uses
dxBackend.ConnectionString.JSON, // Declares the TdxBackendInMemoryJSONConnection component
dxReport, // Declares the TdxReport component
dxShellDialogs; // Declares the TdxSaveFileDialog component
// ...
procedure TMyForm.cxButtonExportToPDFClick(Sender: TObject);
var
AReport: TdxReport;
AJSONDataConnection: TdxBackendInMemoryJSONConnection;
AJSONData: string;
begin
// Define a table that consists of three columns ("id", "Region", and "Sales") and five data rows
AJSONData :=
'[{"id": 1, "Region": "Asia", "Sales": 4.7685},' + // Row #1
'{"id": 2, "Region": "Australia", "Sales": 1.9576},' + // Row #2
'{"id": 3, "Region": "Europe", "Sales": 3.3579},' + // Row #3
'{"id": 4, "Region": "North America", "Sales": 3.7477},' + // Row #4
'{"id": 5, "Region": "South America", "Sales": 1.8237}]'; // Row #5
if not dxSaveFileDialog1.Execute(Handle) then Exit; // Displays the "Save File" dialog
AJSONDataConnection: := TdxBackendInMemoryJSONConnection.Create(Self); // Creates a data connection
try
AJSONDataConnection.Name := 'JSONData'; // Assigns a name to the created data connection
AJSONDataConnection.SetJSONValue(AJSONData); // Assigns the defined JSON data string
AReport := TdxReport.Create(Self); // Creates a TdxReport component
try
AReport.Layout.LoadFromFile('MyReportLayout.repx'); // Loads an XML-based report layout
AReport.ReportName := 'MyReport'; // Defines a report name
AReport.ExportToPDF(dxSaveFileDialog1.FileName); // Saves report content to a file
finally
AReport.Free; // Releases the TdxReport component
end;
finally
AJSONDataConnection.Free; // Releases the data connection component
end;
end;
Related GitHub-Hosted Example
This example bypasses the Report Viewer dialog and generates a report using the DevExpress Reports Backend. You can use the demonstrated technique to implement REST/Web API backends, Windows Services, workflows, and scheduled jobs for the following usage scenarios:
- Bulk export reports to PDF, DOCX, image, and other supported formats.
- Share, email, and print report documents without user interaction.
- Implement custom report management UIs.
Related Compiled Demo
To see the TdxReport print and export functionality in action, run the Report Designer/Viewer demo in the VCL Demo Center installed with compiled DevExpress VCL demos. Click different items in the sidebar on the left to select different demos. Click the Print Preview button to display the Print Preview dialog. Use built-in UI elements to test built-in export functionality.
Tip
You can find full source code for the installed compiled Report demo in the following folder:
%PUBLIC%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressReports\