本文介绍了我如何序列化DevEx preSS XtraReport报表设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要序列化报表设计。这是该方案:

I need to serialize a report design. This is the scenario:

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

The app has base reports, let's say "Sales Report" with a set of pre-defined columns and design, like the corp. logo in the header. The users needs to have the ability to change that layout adding, for example, a footer with the office address, or page numbers. For doing that they need to edit the report, enter the designer and add/change what they need. This changed report layout needs to be serialized to be stored in the database for that user, so the next time, the user opens that report, using that design.

有道理?

推荐答案

下面是我如何做到这一点的简化版本:

Here's a simplified version of how I do this:

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类:

Inside MySaveCommandHandler class:

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;
}

这篇关于我如何序列化DevEx preSS XtraReport报表设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 16:35