TdxReport.ExportToImage(TStream) Method
Exports report content to a stream in the current image export format.
Declaration
procedure ExportToImage(AStream: TStream);
Parameters
Name | Type | Description |
---|---|---|
AStream | TStream | The target stream. |
Remarks
Call the ExportToImage
procedure to export report content to a stream (as a synchronous operation) in the current image format. The ExportTimeout property specifies the timeout interval (in milliseconds) for synchronous export operations.
Image Export Format 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):
Code Example: Export Reports to Image Files
The following code example loads an XML-based report template (TdxReport.Layout) from a REPX file, populates the template with test data defined in a connection string, and exports the resulting report as a PNG image:
uses
dxReport, // Declares the TdxReport component and related types
dxReport.ConnectionString.JSON; // Declares the TdxReportInMemoryJSONConnection component
// ...
procedure TMyForm.Button1Click(Sender: TObject);
var
AJSONDataConnection: TdxReportInMemoryJSONConnection;
AReport: TdxReport;
AFileStream: TFileStream;
begin
AJSONDataConnection := TdxReportInMemoryJSONConnection.Create(Self);
try
AJSONDataConnection.Name := 'JSONData';
// Specify in-memory report data as a connection string
AJSONDataConnection.ConnectionString :=
'Json=''[{"id":1, "caption":"test1"},{"id":2, "caption":"test2"}]''';
AReport := TdxReport.Create(Self);
try
AReport.ReportName := 'Report';
AReport.Layout.LoadFromFile('Report.repx'); // Loads a report template
AFileStream := TFileStream.Create('Report.png', fmOpenReadWrite);
try
AReport.ExportToImage(AFileStream); // Exports the report in the default image export format (PNG)
finally
AFileStream.Free;
end;
finally
AReport.Free;
end;
finally
AJSONDataConnection.Free;
end;
end;
Asynchronous Export Operations
Call the StartExportAsync procedure to initiate an asynchronous report export operation. To receive asynchronous export results, handle the OnExported event.