XtraReport.FromStream(Stream, Boolean) Method
Loads the report definition data from the specified stream and creates a report object from it. The created report’s class is also specified in the REPX data format.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.2.dll
NuGet Package: DevExpress.Reporting.Core
#Declaration
public static XtraReport FromStream(
Stream stream,
bool loadState = true
)
#Parameters
Name | Type | Description |
---|---|---|
stream | Stream | The Stream object containing the REPX or XML data to load. |
#Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
load |
Boolean | True | true to load the report’s state that is also saved in the REPX or XML data; otherwise, false. |
#Returns
Type | Description |
---|---|
Xtra |
An Xtra |
#Remarks
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
Use this method to create a report instance from the report definition data stored in the specified stream. Note that to be able to create the report, this method should find the class type of the report being created (the report class type name is stored in the REPX data header). This type is searched for in the following assemblies:
- The assembly (the .EXE or .DLL file) that produced the report definition data. Its path is also mentioned in the report definition’s header.
- The current assembly where the FromStream method is called.
- The assemblies referenced by the current assembly.
- The loaded assemblies.
If this class type is not found, an instance of the XtraReport class is created.
The saved state can be applied to the created report instance if the loadState parameter is set to true.
#Example
This example demonstrates how to save a report definition to a stream (assigned to a corresponding Session object) as a REPX file and restored back by using the XtraReport.SaveLayout and XtraReport.FromStream methods.
using System.IO;
using DevExpress.XtraReports.UI;
// ...
private void StoreReport(XtraReport report) {
// Create a stream.
MemoryStream stream = new MemoryStream();
// Save a report to the stream.
report.SaveLayout(stream);
// Save the stream to a session.
Session["report_stream"] = stream;
}
private XtraReport RestoreReport() {
// Restore the stream from the session.
MemoryStream stream = (MemoryStream)Session["report_stream"];
// Create a report from the stream.
return XtraReport.FromStream(stream, true);
}
#Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the FromStream(Stream, 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.