Skip to main content

XtraReport.FromXmlStream(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 XML data format.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v23.2.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

public static XtraReport FromXmlStream(
    Stream stream,
    bool loadState = true
)

Parameters

Name Type Description
stream Stream

The Stream object that contains the XML data to load.

Optional Parameters

Name Type Default Description
loadState Boolean True

true, to load the report’s state which is also saved in the XML data; otherwise, false.

Returns

Type Description
XtraReport

An XtraReport class or its descendant of the type specified in the XML data.

Remarks

Use the FromXmlStream method to create a report instance from the report definition data stored in the specified stream. To create the report, this method should find the report’s class type. The class type name is stored in the XML data header. This type is searched for in the following assemblies:

  1. In the current assembly where the FromXmlStream method is called from;
  2. In the assemblies referenced by the current assembly;
  3. In the loaded assemblies.

If this class type is not found, an instance of the XtraReport class is created.

Set the loadState parameter to true to apply the saved state to the created report instance.

Example

This example demonstrates how to use the XtraReport.SaveLayoutToXml method to save a report definition to a stream (assigned to a corresponding ASP.NET Session) as an XML file, and how to use the XtraReport.FromXmlStream method to restore the report definition.

using System.IO;
using DevExpress.XtraReports.UI;
// ...
private MemoryStream report_stream;
private void StoreReport(XtraReport report) {
    // Create a stream. 
    MemoryStream stream = new MemoryStream();

    // Save a report to the stream. 
    report.SaveLayoutToXml(stream);

    // Save the stream to a session. 
    this.report_stream = stream;
}

private XtraReport RestoreReport() {
    // Restore the stream from the session. 
    MemoryStream stream = (MemoryStream)this.report_stream;

    // Create a report from the stream. 
    return XtraReport.FromXmlStream(stream, true);
}
See Also