Skip to main content
All docs
V25.2
  • TdxReport Class

    An AI-powered Report Generator component.

    Declaration

    TdxReport = class(
        TcxCustomComponent
    )

    Remarks

    TdxReport is a non-visual component designed to generate customizable reports based on templates populated with placeholder fields. The report generator implementation is based on the DevExpress Javascript Report Designer and Viewer adapted for use in native VCL apps (using modern web-based design capabilities based on WebView and ASP.NET Core).

    All required .NET and JS dependencies are embedded into one self-contained EXE file transparently.

    VCL Reports: A Report Template Design Example

    Bind to Data

    TdxReport can populate placeholder fields in a template from different data sources stored in memory or a database. The TdxBackendDataConnectionManager component allows you to manage data connection components designed to work with different data sources.

    Tip

    You can create data connection components directly in code, without TdxBackendDataConnectionManager.

    Refer to data connection class descriptions for detailed information and code examples.

    Data Connection Components

    TdxBackendInMemoryJSONConnection
    A component designed for interaction with data stored in memory (in the JSON format).
    TdxBackendDataSetJSONConnection

    A component designed to work with data in one or multiple VCL-compatible datasets (TDataSet descendants).

    Use the TdxBackendDataSetJSONConnection component if you need to use Web-based TdxDashboardControl and TdxReport components together with VCL-compatible data sources.

    TdxBackendDatabaseSQLConnection

    A DevExpress XPO-based component designed to fetch data from an SQL database (SQL Server, PostgreSQL, SQLite, etc.).

    Tip

    This component is based on the DevExpress XPO ORM engine (powered by ADO.NET). [TdxBackendDatabaseSQLConnection] has built-in support for Microsoft SQL/Azure SQL and SQLite engines (you can use them without additional dependencies and extra configuration).

    Refer to the following topic for a complete list of supported database engines and corresponding connection string examples: VCL Backend: Supported Database Engines.

    Main API Members

    The list below outlines key members of the TdxReport class. These members allow you to configure templates, generate reports, and export report content in different target formats.

    Report Content and Layout

    Clear
    Clears the current report name, layout, and parameters.
    FilterString
    Specifies filter criteria for report data.
    GroupName
    Allows you to group multiple TdxReport components. All components within the same group use shared VCL backend resources.
    Language
    Allows you to switch between available UI and report template localizations. Refer to the following topic for information on localization techniques: VCL Reports Localization.
    Layout
    Provides access to the report REPX template (as individual XML strings).
    LoadParametersFromReport
    Populates the Parameters collection using the current report layout as a source.
    OnLayoutChanged
    Allows you to respond to any report layout changes.
    Parameters
    Provides access to the collection of report parameters.
    ReportName
    Specifies the report name.

    End-User Interaction

    ExportFormats
    Specifies export formats available to users in the Report Preview dialog.
    OnBrowserFileDownload
    Allows you to execute custom code in response to preview file download operations or to prevent users from downloading previews.
    OnPrintPreview
    Allows you to respond to print preview operations and obtain preview content as a PDF document.
    ShowDesigner | ShowViewer

    Display Web-based Report Designer and Report Preview dialogs. Global skin and palette settings (defined using the Project Settings dialog or a TdxSkinController component) affect these dialogs.

    Tip

    You can click the Designer… or Viewer… item in the TdxReport component’s context menu to display the corresponding dialog at design time.

    Data Export

    ExportTimeout
    Specifies a timeout interval (in milliseconds) for all synchronous export operations.
    ExportTo
    Exports the current report to a stream in any supported format.
    ExportToCSV | ExportToDOCX | ExportToHTML | ExportToMHT | ExportToPDF | ExportToRTF | ExportToRTF | ExportToText | ExportToXLS | ExportToXLSX
    Export the current report to a stream in corresponding formats.
    ExportToImage

    Exports the current report to a stream as an image (PNG is the default image export format).

    Tip

    The current image format is defined in Export Options available in the Web-based Report Preview dialog.

    GetExportResultFileName
    Returns the full report file name for export operations.

    Code Examples

    View Example: Store Report Layouts within Text Files View Example: Store Report Layouts in a Database View Example: Localize the DevExpress Report Viewer and Report Designer

    Connect to an SQL Database and Edit Report Templates

    The following code example uses the TdxBackendDatabaseSQLConnection component to connect to a demo database (nwind.mdb), displays the Report Designer dialog, and saves all changes made to the UserReport.repx file:

    uses
      dxReport,  // Declares the TdxReport component and related types
      dxBackend.ConnectionString.SQL;  // Declares the TdxBackendDatabaseSQLConnection component
    // ...
    
    procedure TMyForm.Button1Click(Sender: TObject);
    var
      ADataConnection: TdxBackendDatabaseSQLConnection;
      AReport: TdxReport;
    begin
      ADataConnection := TdxBackendDatabaseSQLConnection.Create(Self);
      try
        ADataConnection.Name := 'DataConnection';
        // Specify a connection string required to connect to a demo database (nwind.mdb)
        ADataConnection.ConnectionString := 'XpoProvider=MSAccess;Provider=Microsoft.ACE.OLEDB.12.0;' +
          'Data Source=C:\Users\Public\Documents\DevExpress VCL Demos\' +
          'MegaDemos\Product Demos\ExpressPivotGrid\Data\nwind.mdb';
        AReport := TdxReport.Create(Self);
        try
          AReport.ShowDesigner;  // Displays the Web-based Report Designer dialog
          AReport.Layout.SaveToFile('UserReport.repx');  // Saves the report template state to a file
        finally
          AReport.Free;
        end;
      finally
        ADataConnection.Free;
      end;
    end;
    

    To see the TdxReport component in action, run the Report Designer/Viewer demo in the VCL Demo Center installed with compiled VCL DevExpress demos. Click different items in the sidebar on the left to switch between demo features.

    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\

    See Also