The requested page is not available for the requested platform. You are viewing the content for Default platform.

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.v19.1.dll

Declaration

public static XtraReport FromStream(
    Stream stream,
    bool loadState = true
)
Public Shared Function FromStream(
    stream As Stream,
    loadState As Boolean = True
) As XtraReport

Parameters

Name Type Description
stream Stream

The Stream object containing the REPX or 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 REPX or XML data; otherwise, false.

Returns

Type Description
XtraReport

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

Remarks

Important

Deserialization of reports obtained from untrusted parties can trigger execution of malicious code that can either be directly embedded into the report definition, or contained in an external assembly referenced by the report.

To avoid this, we recommend that you use XML serialization instead of CodeDOM and prevent any untrusted third-party libraries from becoming available on the server.

When a reporting application is deployed under the Medium Trust permission level, XML serialization is the only option to save reports (CodeDOM serialization is not supported in such environment).

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 creating report (the report class's type name is stored in the REPX data header). This type is searched for in the following assemblies:

  1. In the assembly (represented by the .EXE or .DLL file) which produced the report definition data. Its path is also mentioned in the report definition's header;
  2. In the current assembly where the FromStream method is called from;
  3. In the assemblies referenced by the current assembly;
  4. In 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.

Examples

This example demonstrates how to save a report definition to a stream (assigned to a corresponding ASP.NET Session) 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);
}
See Also