xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xtrareport-dot-fromxmlfile-x28-system-dot-string-system-dot-boolean-x29.md
Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.
Loads the serialized report definition from the specified XML file.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public static XtraReport FromXmlFile(
string path,
bool loadState = true
)
Public Shared Function FromXmlFile(
path As String,
loadState As Boolean = True
) As XtraReport
| Name | Type | Description |
|---|---|---|
| path | String |
The full path (including the file name and extension) to the XML file.
|
| 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.
|
| Type | Description |
|---|---|
| XtraReport |
An XtraReport class (or its descendant, the type of which is specified in the XML file).
|
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:
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.
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);
}
Imports DevExpress.XtraReports.UI
' ...
Private Sub StoreReport(ByVal report As XtraReport)
' Save a report to the stream.
report.SaveLayoutToXml("..\\..\\XtraReport1.xml")
End Sub
Private Function RestoreReport() As XtraReport
' Create a report from the stream.
Return XtraReport.FromXmlFile("..\\..\\XtraReport1.xml", True)
End Function
See Also