Note注意

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

下面的示例演示了如何通过 XtraReport.SaveLayout 方法把报表定义保存到 REPX 文件,然后如何通过 XtraReport.LoadLayout 方法加载报表定义。 要查看总说明,请参阅 存储报表定义

C#CopyCode image复制代码
// A temporary path to save a report to.
string filePath = @"C:\Temp\XtraReport1.repx";

private void button1_Click(object sender, System.EventArgs e) {
    // Create a report.
    XtraReport1 report = new XtraReport1();

    // Save a report's layout to the configuration file.
    report.SaveLayout(filePath);
}

private void button2_Click(object sender, System.EventArgs e) {
    // Create a report.
    XtraReport1 report = new XtraReport1();

    // Load a report's layout from the specified file.
    report.LoadLayout(filePath);

    // Display the print preview.
    report.ShowPreview();
}
Visual BasicCopyCode image复制代码
' A temporary path to save a report to.
Dim FilePath As String = "C:\Temp\XtraReport1.repx" 

Private  Sub OnButton1Click(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Button1.Click
    ' Create a report.
    Dim Report As XtraReport1 =  New XtraReport1() 

    ' Save a report's layout to the configuration file.
    Report.SaveLayout(FilePath)
End Sub

Private  Sub OnButton2Click(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Button2.Click
    ' Create a report.
    Dim Report As XtraReport1 =  New XtraReport1() 

    ' Load a report's layout from the specified file.
    Report.LoadLayout(FilePath)

    ' Display the print preview.
    Report.ShowPreview()
End Sub

CodeCentralShow Me

在 DevExpress Code Central 数据库中可以找到完整的示例项目,网址是 http://www.devexpress.com/example=E1279。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。

Expand image参阅