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

    Prerequisites & Deployment

    Ensure that your development environment meets ExpressDashboards and ExpressReports prerequisites:

    1. Microsoft Windows 10 or newer.
    2. Embarcadero RAD Studio IDE 12.3 or newer (Community Edition IDEs are not supported).
    3. DevExpress VCL v25.2.x. (You must own a VCL Subscription+ license or DevExpress VCL and Universal licenses).
    4. The EdgeView2 SDK package installed from the GetIt package manager.

    Tip

    Refer to the following topic for detailed information: VCL Reports/Dashboards App Deployment.

    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 the data connection class descriptions for detailed information and code examples.

    Data Connection Components

    TdxBackendInMemoryJSONConnection

    A component designed for interaction with local (in-memory) or remote JSON data accessible through a Web API service endpoint.

    Refer to the following help topic for step-by-step instructions on using the TdxBackendInMemoryJSONConnection component as a data source for TdxDashboard/TdxDashboardControl and TdxReport.

    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 TdxDashboardControl/TdxDashboard and TdxReport components together with VCL-compatible data sources.

    TdxBackendDatabaseSQLConnection

    A DevExpress XPO-based component designed to fetch data from the following relational databases:

    SQLite | Microsoft SQL Server/Azure SQL | PostgreSQL | Oracle Database | MySQL | Firebird

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

    Specifies if custom SQL queries are enabled at the TdxReport component level.

    Important

    Enable custom SQL queries only if you ensure that you follow best practices and implement user read/write privileges at the database level using the tools available for your relational database management system.

    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).
    OnLayoutChanged
    Allows you to respond to any report layout changes.
    Parameters

    Provides access to the collection of report parameters.

    Note

    The Parameters collection is initially empty. Call the Parameters.LoadFromLayout procedure to populate the collection from the current report layout definition.

    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.
    OnDesignerFormShow | OnViewerFormShow
    Allow you to customize Report Designer and Report Viewer dialog form settings (position, dimensions, caption, etc.).
    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

    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 a SQL Database and Edit Report Templates

    The following code example uses the TdxBackendDatabaseSQLConnection component to connect to a demo database (devav.sqlite3), 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); // Creates a database connection
      try
        ADataConnection.Name := 'SQLite Database Connection';
        // Specify a connection string required to connect to a demo database (devav.sqlite3)
        ADataConnection.ConnectionString := 'XpoProvider=SQLite;' +  // Specifies the database engine type
          'Data Source=C:\Users\Public\Documents\DevExpress VCL Demos\MegaDemos\' +
          'Product Demos\ExpressReports\Data\devav.sqlite3';
        AReport := TdxReport.Create(Self);               // Creates a TdxReport component
        try
          AReport.ShowDesigner;                          // Displays the Report Designer dialog
          AReport.Layout.SaveToFile('UserReport.repx');  // Saves the report template state to a file
        finally
          AReport.Free;          // Releases the created TdxReport component
        end;
      finally
        ADataConnection.Free;    // Releases the database connection component
      end;
    end;
    

    To see the TdxReport component in action, run the Report Designer/Viewer demo in the VCL Demo Center installed with compiled DevExpress VCL 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