Skip to main content

Load Report Layouts

  • 4 minutes to read

This document describes how to load a report from the report layout (report definition) file that contains serialization data.

Load Reports with the Report Designer UI

Click the report’s smart tag and select Open/Import in the actions list to load a report definition file. The default file extension is REPX.

open-import-report-visual-studio-design-time

The Import Report dialog displayed in Visual Studio enables you to import reports produced by third-party vendors. This option is not available in End-User Report Designers.

import-dialog-visual-studio

The End-User Report Designer UI for the desktop (WinForms and WPF) has an Open button to load reports.

The Web Report Designer enables the Open button if a report storage is implemented.

After you load a report, you may have to update data bindings. Refer to the following help topic for more information: Update Expression Bindings in Controls.

Load a Report in Code

Use the following API to load reports and report style sheets in code:

Recommended API

Legacy API

XtraReport.LoadLayoutFromXml

Loads a report from a file or stream that contains serialization data in XML format.

XtraReport.FromXmlFile

Loads the serialized report definition from the specified XML file.

XtraReport.FromXmlStream

Loads the report definition data from the specified stream and creates a report object from it. The created report’s class is also specified in the XML data format.

XtraReport.LoadLayout

Loads a report from a CodeDOM object model or from XML serialization data contained in a file or stream.

XtraReport.FromFile and XtraReport.FromStream

These static methods attempt to identify the report class type and deserializes a report to an instance of that class.

The name of the report class type is stored in the header of the report definition. The report class type lookup is performed in the following assemblies (in the order specified below):

  1. The assembly (an EXE or DLL file) that produced the report definition. The assembly path is specified in the report definition’s header.
  2. The current assembly.
  3. Other assemblies referenced by the current assembly.

If the class type cannot be determined, a new instance of the base class XtraReport is created with the layout and settings loaded from the report definition file.

XRControlStyleSheet.LoadFromXml

Loads an XML containing a report’s style sheet from a file or stream.

XRControlStyleSheet.LoadFromFile and XRControlStyleSheet.LoadFromStream

Loads a report’s style sheet from a CodeDOM object model contained in a file or stream.

Note

We recommend using XML serialization to prevent unauthorized code injections into a report’s definition and execution of harmful code on a client machine when deserializing CodeDOM reports.

For more information, refer to the following help topic: DevExpress Reporting - Security Considerations.

The following code loads a report from the file:

// A path to a report's definition file.
string reportFilePath = @"C:\Temp\Report1.repx";

// A path to a report style sheet.
string styleSheetFilePath = @"C:\Temp\ReportStyleSheet1.repss";

private void button1_Click(object sender, System.EventArgs e) {
    // Create a report instance.
    XtraReport1 report = new XtraReport1();

    // Load a report's layout from XML.
    if (System.IO.File.Exists(reportFilePath)) {
        report.LoadLayoutFromXml(reportFilePath);
    } 
    else {
        System.Console.WriteLine("The source file does not exist.");
    }

    // Load a report's style sheet from XML.
    if (System.IO.File.Exists(styleSheetFilePath)) {
        report.StyleSheet.LoadFromXml(styleSheetFilePath);
    } 
    else {
        System.Console.WriteLine("The source file does not exist.");
    }
}

For more information on report serialization, review the following help topics:

Secure Report Loading

The End-User Report Designer (WinForms and WPF) displays a warning when the user tries to load a potentially harmful report:

report-designer-load-report-warning

A report is considered insecure if any of the following contents are found in it (or in any of its subreports):

If you have not yet done so, be sure to review the following help topic: DevExpress Reporting - Security Considerations.

Review the following help topics for information on how to ensure user security:

See Also