XtraReport.FromXmlFile(String, Boolean) Method
Loads the serialized report definition from the specified XML file.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.2.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
Parameters
Name | Type | Description |
---|---|---|
path | String | The full path (including the file name and extension) to the XML file. |
Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
loadState | Boolean | True | true to restore the report’s property values along with the settings applied to its elements (bands and controls); false to load only the report’s base type settings. |
Returns
Type | Description |
---|---|
XtraReport | An XtraReport class (or its descendant, the type of which is specified in the XML file). |
Remarks
Use the FromXmlFile method to restore a report from its definition file stored in serialized XML format.
To be able to restore the report class settings, this method should locate the associated report type based on which the specified report definition file was created. This type is searched for in the following assemblies:
- In the current assembly (from which the FromXmlFile method is called);
- In the assemblies referenced by the current assembly;
- In the loaded assemblies.
When this method fails to locate the original class type, it creates a new XtraReport class instance.
Call this method with its loadState parameter set to true to restore all custom report property values and element property values.
Note
Set loadState to true in most scenarios, because the report specified in the definition file can be of the XtraReport type (for instance, when a report was saved in the Visual Studio report designer). In this case, the false value in the loadState parameter causes the application to generate an empty report.
Example
This example demonstrates how to use the XtraReport.FromXmlFile method to restore a report definition from a file.
In the example, this method is called with its loadState parameter set to true, and restores a report’s custom property values and element property values.
To run the example, the application must successfully locate the assembly based on which the specified XtraReport1.xml file was created (either in the original project folder, among the assembly references, or in the GAC).
using DevExpress.XtraReports.UI;
// ...
private void StoreReport(XtraReport report) {
// Save a report to the stream.
report.SaveLayoutToXml(@"..\\..\\XtraReport1.xml");
}
private XtraReport RestoreReport() {
// Create a report from the stream.
return XtraReport.FromXmlFile(@"..\\..\\XtraReport1.xml", true);
}