TdxReport.ExportToDOCX(string) Method
Exports report content to a file as an Office OpenXML (DOCX) document.
Declaration
procedure ExportToDOCX(const AFileName: string); overload;
Parameters
| Name | Type | Description |
|---|---|---|
| AFileName | string | An absolute or relative path to the target file. |
Remarks
Call the ExportToDOCX procedure to export report content to a file in the DOCX format.
DOCX Export Settings
The Report Designer dialog allows you to configure DOCX export settings. Open the Properties tab and expand the following nodes to modify DOCX export settings: Behavior | Export Options | DOCX Export Options.

Code Example: Export Report Content to DOCX 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 DOCX format:
uses
dxBackend.ConnectionString.JSON, // Declares the TdxBackendInMemoryJSONConnection component
dxReport, // Declares the TdxReport component
dxShellDialogs; // Declares the TdxSaveFileDialog component
// ...
procedure TMyForm.cxButtonExportToDOCXClick(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.ExportToDOCX(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 Compiled Demo
To see the report export functionality in action, run the Report Designer/Viewer demo in the VCL Demo Center installed with compiled DevExpress VCL demos. Select any demo in the sidebar on the left, click the Export button, and use any export option listed in the menu.
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\
Other Export Methods
Export to File
- ExportTo
- Exports report content to a stream in any supported format.
- ExportToCSV
- Exports report content to a file in the comma-separated values (CSV) format.
- ExportToHTML
- Exports report content to a file as an HTML document.
- ExportToImage
Exports report content to a stream in the current image export format (selected using the Report Designer dialog).
The default image export format is PNG (Portable Network Graphics).
- ExportToMHT
- Exports report content to a MIME HTML (MHT) document file.
- ExportToPDF
- Exports report content to a PDF file.
- ExportToRTF
- Exports report content to an RTF document file.
- ExportToText
- Exports report content to a plain text file.
- ExportToXLS
- Exports report content to a file in the Microsoft Excel® binary format (XLS).
- ExportToXLSX
- Exports report content to a file in the Office Open XML spreadsheet format (XLSX).
Export to Stream
- ExportTo
- Exports report content to a stream in any supported format.
- ExportToCSV
- Exports report content to a stream in the comma-separated values (CSV) format.
- ExportToDOCX
- Exports report content to a stream as an Office OpenXML (DOCX) document.
- ExportToHTML
- Exports report content to a stream as an HTML document.
- ExportToImage
Exports report content to a stream in the current image export format (selected using the Report Designer dialog).
The default image export format is PNG (Portable Network Graphics).
- ExportToMHT
- Exports report content to a stream as a MIME HTML (MHT) document.
- ExportToPDF
- Exports report content to a stream in the PDF format.
- ExportToRTF
- Exports report content to a stream as an RTF-formatted string.
- ExportToText
- Exports report content to a stream as plain text.
- ExportToXLS
- Exports report content to a stream in Microsoft Excel® binary format (XLS).
- ExportToXLSX
- Exports report content to a stream in Office Open XML spreadsheet format (XLSX).