XtraReport.FromFile(String, Boolean) Method
Loads the report definition from the specified REPX file.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.2.dll
NuGet Package: DevExpress.Reporting.Core
#Declaration
public static XtraReport FromFile(
string path,
bool loadState = true
)
#Parameters
Name | Type | Description |
---|---|---|
path | String | A String value, specifying the full path (including the file name and extension) to the REPX or XML file. |
#Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
load |
Boolean | True | true to restore the property values of a report along with the settings applied to its elements (bands and controls); false to load only the base type settings of the specified report. |
#Returns
Type | Description |
---|---|
Xtra |
An Xtra |
#Remarks
Use the FromFile method to restore a report from its definition file (stored in the standard REPX, or a custom XML format).
Note
DevExpress Reports default configuration prohibits Codetrue
at application startup to allow Code
To avoid this, we recommend that you use XML serialization instead of Code
The Code
To restore the report class settings, this method must locate the associated report type based on which specified report definition file was created. This type is searched for in the following assemblies:
- In the assembly (an EXE or DLL file) that produced the report definition file. Its path is also mentioned in the definition file’s header.
- In the current assembly (from which the FromFile method is called).
- In the assemblies referenced by the current assembly.
- In the loaded assemblies.
When this method fails to locate the originating class type, it creates a new XtraReport class instance.
Calling this method with its loadState parameter set to true will restore all custom property values of both a report and its elements.
Note
You can set the load
#Example
This example demonstrates how to restore a report definition from a file by using the XtraReport.FromFile method.
In the following code, this method is called with its loadState parameter set to true, restoring all custom property values of both a report and its elements.
To run the following code, the application must successfully locate the assembly based on which the specified XtraReport1.repx file was created (either in the original project folder, among the assemblies referenced by the example, or in the GAC).
using System;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
// ...
private void Form1_Load(object sender, EventArgs e) {
// Restore a report from a file.
XtraReport report = XtraReport.FromFile(@"..\\..\\XtraReport1.repx", true);
// Show the report's Print Preview.
ReportPrintTool printTool = new ReportPrintTool(report);
printTool.ShowPreviewDialog();
}
#Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the FromFile(String, Boolean) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.