Skip to main content
All docs
V25.2
  • TdxReport.ExportToImage(TStream) Method

    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).

    Declaration

    procedure ExportToImage(AStream: TStream); overload;

    Parameters

    Name Type Description
    AStream TStream

    The target stream.

    Remarks

    Call the ExportToImage procedure to export report content to a stream in the current image format.

    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):

    VCL Reports: Image Export Settings in the Report Designer Dialog

    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
      dxBackend.ConnectionString.JSON;  // Declares the TdxBackendInMemoryJSONConnection component
    // ...
    
    procedure TMyForm.Button1Click(Sender: TObject);
    var
      AJSONDataConnection: TdxBackendInMemoryJSONConnection;
      AReport: TdxReport;
      AFileStream: TFileStream;
    begin
      AJSONDataConnection := TdxBackendInMemoryJSONConnection.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;
    

    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.

    Download: Compiled VCL Demos

    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.
    ExportToDOCX
    Exports report content to a file as an Office OpenXML (DOCX) document.
    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.
    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).
    See Also