Skip to main content
All docs
V26.1
  • 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.v26.1.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 Session object) 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);
    }
    

    The following code snippet (auto-collected from DevExpress Examples) contains a reference to the FromXmlStream(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.

    See Also