Save Report Layouts

This document describes how to save report layouts created in Visual Studio or end-user Report Designers.

Tip

See Store Report Layouts for general information about storing reports.

Saving Reports using Application GUI

You can save a report definition in the Visual Studio Report Designer by clicking the report's smart tag and selecting Save in its actions list.

save-report-defintion-visual-studio-design-time

In Visual Studio, you can select the serialization format for a saved report (XML or CodeDOM).

save-as-dialog-visual-studio

XML serialization is used to save report layouts by default.

Important

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.

See Reporting Security for more information on security considerations related to storing and distributing DevExpress reports.

End-User Report Designers allow saving reports to XML only by default.

Tip

End-User WinForms and WPF Report Designers provide the Save and Save As buttons for saving reports.

The Web Report Designer provides these buttons after implementing and registering a report storage.

Saving Reports in Code

You can use the following API to save reports and report style sheets in code:

Recommended API

Legacy API

XtraReport.SaveLayoutToXml

Saves a report to a file or stream in XML format.

XtraReport.SaveLayout

Saves a report to a file or stream as a Code Document Object Model (CodeDOM) graph.

XRControlStyleSheet.SaveXmlToFile and XRControlStyleSheet.SaveXmlToStream

Saves a report's style sheet to a file or stream in XML format.

XRControlStyleSheet.SaveToFile and XRControlStyleSheet.SaveToStream

Saves a report's style sheet to a file or stream as a CodeDOM graph.

In the latest DevExpress Reports versions, XML serialization is used by default to save reports and report style sheets created in Visual Studio and end-user Report Designers.

Important

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.

See Reporting Security for more information on security considerations related to storing and distributing DevExpress reports.

The following code illustrates the recommended approach to saving reports:

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

// The 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();

    // Save the report's layout to XML.
    report.SaveLayoutToXml(reportFilePath);

    // Save the report's style sheet to XML.
    report.StyleSheet.SaveXmlToFile(styleSheetFilePath);
}
Tip

See the following topics to learn about the supported serialization formats:

See Also