Skip to content

DevExpress-Examples/vcl-reports-store-layout-template-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevExpress Reports for Delphi/C++Builder – Import and Save Report Layouts to XML Files

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.

An application with buttons to create a new report, import and save reports, open a report designer and report viewer


Prerequisites

DevExpress Reports Prerequisites

Test the Example

Modify and Save the Pre-loaded Layout to a New File

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.

  1. Build and run the sample application. Note that the app window caption displays the preloaded layout's name.
  2. Click Open Designer to edit the loaded layout in the DevExpress Report Designer. Modify the layout as you see fit.
  3. Click the hamburger button, select Save, and close the dialog.
  4. Click Save to File to save the report layout to a REPX file. You can overwrite an existing file or create a new file.
  5. Restart the application and click Import from File to import a report layout from the previously saved REPX file.
  6. Click Open Viewer to display the imported layout in the DevExpress Report Viewer.

Create, Design, and Save a New Layout

You can design a new layout from scratch and save it to a REPX file:

  1. Build and run the sample application.
  2. Click Create New to open a new blank report layout in the DevExpress Report Designer.
  3. Design the report layout (template) using tools available in the Report Designer.
    Follow the tutorial: Create a table report using the Report Wizard.
  4. Click the hamburger button, select Save, and input a report layout name. Click Save and close the dialog.
  5. Click Save to File to save the report layout to a REPX file.
  6. Restart the application and click Import from File to import a report layout from the previously saved REPX file.
  7. Click Open Viewer to display the imported layout in the DevExpress Report Viewer.

Implementation Details

Import a Report Layout from a File

To import (load) a report layout from a file, call the Layout.LoadFromFile method and assign a name to the ReportName property:

Delphi

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;

C++Builder

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.

Save a Report Layout to a File

To save the current report layout to a file, call the Layout.SaveToFile method:

Delphi

procedure TMainForm.SaveReport(const AFileName: string);
begin
    // Save the report layout to a file
    dxReport1.Layout.SaveToFile(AFileName);
end;

C++Builder

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.

Files to Review

Documentation

More Examples

Does This Example Address Your Development Requirements/Objectives?

(you will be redirected to DevExpress.com to submit your response)

About

This example stores a report layout (XML-based template) within a text file.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors