Skip to main content
All docs
V26.1
  • TdxReport.SaveDocument(TStream) Method

    Exports report content to a stream in the XML-Based Report Archive (PRNX) format.

    Declaration

    procedure SaveDocument(AStream: TStream); overload;

    Parameters

    Name Type Description
    AStream TStream

    The target stream.

    Remarks

    Call the ExportToXLSX procedure to export report content to a stream in the XLSX format. A subsequent LoadDocument call allows you to import the previously generated report document.

    Code Example: Export Report Content to PRNX File

    The following code example configures a memory-based data source (TdxBackendInMemoryJSONConnection), loads an XML layout, and exports generated content to a file in the XML-Based Report Archive (PRNX) format without user interaction:

    uses
      dxBackend.ConnectionString.JSON,  // Declares the TdxBackendInMemoryJSONConnection component
      dxReport;                      // Declares the TdxReport class
    // ...
    
    procedure TMyForm.cxButtonExportToPRNXClick(Sender: TObject);
    var
      AReport: TdxReport;
      AJSONDataConnection: TdxBackendInMemoryJSONConnection;
      AMemoryStream: TMemoryStream;
      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
    
      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 container
        try
          AReport.Layout.LoadFromFile('MyReportLayout.xml');  // Loads an XML Report layout
          AReport.ReportName := 'MyReport';                         // Defines a Report name
          AMemoryStream := TMemoryStream.Create;                    // Creates a memory stream
          try
            // Export Report content to the created memory stream in the PRNX format:
            AReport.SaveDocument(AMemoryStream);
            AMemoryStream.SaveToFile(AReport.ReportName + '.prnx');   // Saves the resulting PRNX file
          finally
            AMemoryStream.Free;         // Releases the memory stream
          end;
        finally
          AReport.Free;              // Releases the TdxReport container
        end;
      finally
        AJSONDataConnection.Free;       // Releases the data connection
      end;
    end;
    

    Other Export Methods

    Export to File

    ExportTo
    ExportToDOCX
    ExportToHTML
    ExportToImage
    ExportToMHT
    ExportToPDF
    ExportToRTF
    ExportToText
    ExportToXLS
    ExportToXLSX
    SaveDocument

    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 in the Office OpenXML (DOCX) document format.
    ExportToHTML
    Exports report content to a stream in the HyperText Markup Language (HTML) document format.
    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 in the MIME HTML (MHT) document format.
    ExportToPDF
    Exports report content to a stream in the Portable Document (PDF) format.
    ExportToRTF
    Exports report content to a stream in the Rich Text (RTF) document format.
    ExportToText
    Exports report content to a stream in the plain text (TXT) document format.
    ExportToXLS
    Exports report content to a stream in the Microsoft Excel® binary (XLS) spreadsheet format.
    ExportToXLSX
    Exports report content to a stream in the Office OpenXML Spreadsheet (XLSX) format.
    See Also