Skip to main content
All docs
V25.2
  • TdxReport.ReportName Property

    Specifies the report name.

    Declaration

    property ReportName: string read; write;

    Property Value

    Type Description
    string

    The report name.

    Remarks

    Use the ReportName property to define a report name for export operations when the Layout property contains a non-empty report template. Report Viewer and Report Designer dialogs also display the ReportName property value in the form caption.

    The GetExportResultFileName function returns the full exported file name composed of the ReportName property value and the file name extension that corresponds to the current export format.

    End-User Functionality

    To save the current report template state during the current session, users can click the hamburger button in the Report Designer dialog and select the Save option. If the TdxReport.ReportName property value is an empty string, the Report Designer dialog prompts a user to specify a report name:

    VCL Reports: The Report Name Dialog

    The report is saved in memory. You can access the report using the Layout property.

    Code Examples

    Save Report Layout Changes to File on Every Change

    The following code example saves the current report to a REPX file every time a user saves pending changes in the Report Designer dialog:

    uses
      dxReport;  // Declares the TdxReport class
    // ...
    
    procedure TMyForm.dxReport1LayoutChanged(ASender: TdxReport);
    begin
      ASender.Layout.SaveToFile(ASender.ReportName + '.repx');
    end;
    

    Save Report Layout to Database on Every Change

    The following code example saves the current report to an existing BLOB dataset field every time a user saves pending changes in the Report Designer dialog:

    uses
      dxReport,  // Declares the TdxReport class
      dxmdaset;  // Declares the TdxMemData class and related types
    // ...
    
    procedure TMyForm.dxReport1LayoutChanged(ASender: TdxReport);
    begin
      dxMemData1.Edit;
      dxMemData1.FieldByName('TemplateName').AsString := ASender.ReportName;
      dxMemData1.FieldByName('TemplateLayout').Assign(ASender.Layout);
      dxMemData1.Post;
    end;
    

    Generate Reports Based on In-Memory Data

    The following code example configures a memory-based data source (TdxBackendInMemoryJSONConnection), loads an XML-based (REPX) report layout, and exports generated report (TdxReport) content to a file in the PDF format:

    uses
      dxBackend.ConnectionString.JSON,   // Declares the TdxBackendInMemoryJSONConnection component
      dxReport,                          // Declares the TdxReport component
      dxShellDialogs;                    // Declares the TdxSaveFileDialog component
    // ...
    
    procedure TMyForm.cxButtonExportToPDFClick(Sender: TObject);
    var
      AReport: TdxReport;
      AJSONDataConnection: TdxBackendInMemoryJSONConnection;
      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
    
      if not dxSaveFileDialog1.Execute(Handle) then Exit; // Displays the "Save File" dialog
    
      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 component
        try
          AReport.Layout.LoadFromFile('MyReportLayout.repx');  // Loads an XML-based report layout
          AReport.ReportName := 'MyReport';           // Defines a report name
          AReport.ExportToPDF(dxSaveFileDialog1.FileName);  // Saves report content to a file
        finally
          AReport.Free;                      // Releases the TdxReport component
        end;
      finally
        AJSONDataConnection.Free;            // Releases the data connection component
      end;
    end;
    

    View Example: Store report layouts within text files View Example: Store report layouts in a database

    Default Value

    The ReportName property’s default value is an empty string.

    The default ReportName property value indicates that the ShowDesigner procedure displays an empty template in the Report Designer dialog, even if the Layout property contains a non-empty template. Any subsequent saved changes made in the Report Designer dialog override both ReportName and Layout property values.

    See Also