Note注意

重要说明: .NET Client Profile Framework 不支持此功能。 要在最终用户的机器上使用此功能,则必须安装完整的 .NET Framework。 更多信息,请参阅 Windows 窗体部署 文档中的 关于 .NET Framework 4.0 Client Profile 的重要说明 小节。

本示例展示了如何把报表定义保存到会话对象,并从中恢复。 XtraReport.SaveLayoutXtraReport.FromStream 方法被用于把报表保存到流,并从流中加载报表。 要查看总说明,请参阅 存储报表定义

C#CopyCode image复制代码
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);
}
Visual BasicCopyCode image复制代码
Imports System.IO
Imports DevExpress.XtraReports.UI
' ...

Private Sub StoreReport(report As XtraReport)
   ' Create a stream.
   Dim stream As New MemoryStream()
   
   ' Save a report to the stream.
   report.SaveLayout(stream)
   
   ' Save the stream to a session.
   Session("report_stream") = stream
End Sub

Private Function RestoreReport() As XtraReport
   ' Restore the stream from the session.
   Dim stream As MemoryStream = CType(Session("report_stream"), MemoryStream)
   
   ' Create a report from the stream.
   Return XtraReport.FromStream(stream, True)
End Function

Expand image参阅