This example uses XML-based REPX files as report layout storage.
Run the app and execute the following actions:
- Customize our predefined layout and save it to a new file.
- Create a new report layout and save it to a file.
- Import a report layout you created earlier from a file.
DevExpress Reports Prerequisites
The example application loads a predefined layout at startup: TableReport.repx. You can modify this preloaded report layout and save changes to a REPX file.
- Build and run the sample application. Note that the app window caption displays the preloaded layout's name.
- Click Open Designer to edit the loaded layout in the DevExpress Report Designer. Modify the layout as you see fit.
- Click the hamburger button, select Save, and close the dialog.
- Click Save to File to save the report layout to a REPX file. You can overwrite an existing file or create a new file.
- Restart the application and click Import from File to import a report layout from the previously saved REPX file.
- Click Open Viewer to display the imported layout in the DevExpress Report Viewer.
You can design a new layout from scratch and save it to a REPX file:
- Build and run the sample application.
- Click Create New to open a new blank report layout in the DevExpress Report Designer.
- Design the report layout (template) using tools available in the Report Designer.
Follow the tutorial: Create a table report using the Report Wizard. - Click the hamburger button, select Save, and input a report layout name. Click Save and close the dialog.
- Click Save to File to save the report layout to a REPX file.
- Restart the application and click Import from File to import a report layout from the previously saved REPX file.
- Click Open Viewer to display the imported layout in the DevExpress Report Viewer.
To import (load) a report layout from a file, call the Layout.LoadFromFile method and assign a name to the ReportName property:
procedure TMainForm.ImportReport(const AFileName: string);
begin
// Import a report layout from a file
dxReport1.Layout.LoadFromFile(AFileName);
// Assign the file's name as an internal report name
dxReport1.ReportName := ChangeFileExt(ExtractFileName(AFileName), '');
end;void __fastcall TMainForm::ImportReport(const String &FileName)
{
// Import a report layout from a file
dxReport1->Layout->LoadFromFile(FileName);
// Assign the file's name as an internal report name
dxReport1->ReportName = ChangeFileExt(ExtractFileName(FileName), "");
}Note
An internal report name may differ from the source REPX file name.
To save the current report layout to a file, call the Layout.SaveToFile method:
procedure TMainForm.SaveReport(const AFileName: string);
begin
// Save the report layout to a file
dxReport1.Layout.SaveToFile(AFileName);
end;void __fastcall TMainForm::SaveReport(const String &FileName)
{
// Save the report layout to a file
dxReport1->Layout->SaveToFile(FileName);
}Note
Internal report names are not stored in REPX files.
- uMainForm.pas (Delphi) and uMainForm.cpp (C++Builder) import and save report layouts to REPX files.
- TableReport.repx contains a report layout designed to generate a customer order report.
- Introduction to DevExpress Reports for Delphi/C++Builder
- Tutorial: Create a table report using the Report Wizard
- Use SQLite as a data source for reports (as demonstrated in the current example)
- Store report layouts in REPX files at design-time
- API reference:
- TdxReport.Layout (an XML-based layout template that can be stored in a file)
- TdxReport.Layout.LoadFromFile
- TdxReport.Layout.SaveToFile
- TdxReport.ReportName (internal report name that is not included in the layout)
- TdxBackendDatabaseSQLConnection (supplies data to reports)
- Store report layouts in a database
- Filter data records in a report
- Generate reports in a backend / service application
- Localize the Report Viewer and Report Designer UI
(you will be redirected to DevExpress.com to submit your response)
