Save Report Layouts
- 3 minutes to read
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.
In Visual Studio, you can select the serialization format for a saved report (XML or CodeDOM).
XML serialization is used to save report layouts by default.
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.
End-User Report Designers save reports in XML format 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 |
---|---|
Saves a report to a file or stream in XML format. |
Saves a report to a file or stream as a Code Document Object Model (CodeDOM) graph. |
XRControlStyleSheet.SaveXmlToFile and XRControlStyleSheet.SaveXmlToStream Saves a report style sheet to a file or stream in XML format. | XRControlStyleSheet.SaveToFile and XRControlStyleSheet.SaveToStream Saves a report style sheet to a file or stream as a CodeDOM graph. |
The most recent versions of Report Designers use XML serialization to save reports and report style sheets.
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 snippet 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: