我需要序列一个报告设计。这是该方案:

在应用程序有基地的报道,让我们说“销售报表”一组预定义的列和设计,如CORP。标志的标题。用户需要有改变这种布局添加,例如能力,与办公地址页脚,或页码。对于这样做,他们需要编辑报表,输入设计,并添加/更改他们需要什么。这个变化的报告布局需要被序列被存储在数据库中为该用户,所以接下来的时间,在用户打开该报告中,用该设计。

有道理?

有帮助吗?

解决方案

下面是我怎么做的简化版本:

XtraReport customReport;
customReport = new MyXtraReport();
byte[] layout = LoadCustomLayoutFromDB();
if (layout != null) {
    using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(layout)) {
        customReport.LoadLayout(memoryStream);
    }
}

using (XRDesignFormEx designer = new XRDesignFormEx()) {
    MySaveCommandHandler customCommands = new MySaveCommandHandler(designer.DesignPanel);
    designer.DesignPanel.AddCommandHandler(customCommands);
    designer.OpenReport(customReport);
    designer.ShowDialog(this);
    if (customCommands.ChangesSaved)
        SaveCustomLayoutToDB(customCommands.Layout);
}

内部MySaveCommandHandler类:

public virtual void HandleCommand(ReportCommand command, object[] args, ref bool handled) {
    if (command != ReportCommand.SaveFileAs && command != ReportCommand.SaveFileAs)
        return;

    using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream()) {
        panel.Report.SaveLayout(memoryStream);
        this.layout = memoryStream.ToArray();
        changesSaved = true;
    }

    panel.ReportState = ReportState.Saved;
    handled = true;
}

其他提示

我想你正在寻找的是SaveLayout方法:

<强>保存报表

YourReport report = new YourReport();

// Save the layout to a file.
report.SaveLayout(@"C:\YourReport.repx");

<强>加载报表

YourReport report = new YourReport();

// Load the layout
report.LoadLayout(@"C:\YourReport.repx");

修改

这里链接到DevExpress的支持网站,说明如何保存报告定义

可以保存/加载到并使用保存并LoadLayout替代流。对于设计者可以添加一个命令处理程序拦截保存命令。

这些文章应该涵盖你所需要的:

如何:保存和还原报表定义流

如何:在最终用户设计器覆盖命令(自定义保存)

和的完整性:的一切是如何对名单

编辑:固定链路

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top