ActiveReports 6 Online Help
Save and Load Report Layout Files (RPX)
Show AllShow All
Hide AllHide All

Although ActiveReports writes report layouts in either C# or Visual Basic.NET, you can save the layout of your report as a report XML (RPX) file for portability. If you make changes to the RPX file and load it back into an ActiveReport in Visual Studio, you can see the changes you made reflected in the C# or Visual Basic.NET code in the YourReportName.Designer.vb or YourReportName.Designer.cs file.

Caution: When you load an RPX layout into a report object, it overwrites everything in the report object. In order to avoid overwriting important layouts, create a new blank ActiveReport and load the RPX file into the new report.

To save a report as an RPX file at design time

  1. In the design view of an ActiveReport, from the Report menu select Save Layout.
  2. Name the file and select the location in which to save it. The file extension is *.rpx.
  3. Click the Save button to save the report layout.
    Note: When you save a layout that contains a dataset, ActiveReports saves the data adapter and data connection in the component tray, but not the dataset itself. When the saved layout is loaded into another report, you can regenerate the dataset with the data adapter and data connection.

To load an RPX file at design time

  1. In the design view of a new, blank ActiveReport, from the Report menu select Load Layout.
  2. Navigate to the RPX file that you want to load and select it.
  3. Click the Open button to load the report layout.

To save a report as an RPX file at run time

Save report layouts before they run. If you save a layout after the report runs, you also save any dynamic changes made to properties or sections in the report. To avoid this when you call SaveLayout inside the report code, use the ReportStart event.

Important: When you save a report layout, ActiveReports only saves the code in the script editor to the file. Any code behind the report in the .cs or .vb file is not saved to the RPX file. For more information, see the Add Code to Layouts Using Script
  1. Right-click on the Windows Form and select View Code from the shortcut menu to see the code view for the Windows form.
  2. Add code to the class to save the report.

The following examples show what the code for the method looks like.

To write the code in Visual Basic.NET

To write the code in C#

Note: The SaveLayout method uses utf-16 encoding when you save to a stream, and utf-8 encoding when you save to a file.

To load a saved RPX file into the ActiveReports viewer

  1. Right-click on the Windows Form to see the code view for the Windows form.
  2. Add the following code to the form class to load a report.

The following examples show what the code for the method looks like.

To write the code in Visual Basic.NET

To write the code in C#

See Also

Concepts

Related Sections