Skip to main content
A newer version of this page is available. .

Combine Reports by Alternating Pages

  • 3 minutes to read

Use report merging to extend table data with graphical data presentation in a report. Design a table report and a report with charts separately and then merge these two reports, alternating between pages that contain tables and ones that contain charts.

Note

There are certain limitations when merging reports.

Design a Table Report

The table report below displays data from the Northwind database’s Products table. The table is grouped by the CategoryID field. The page header band’s Band.PageBreak property is set to Before the Band.

MergeReports_Table_ReportDesigner

MergeReports_Table

Tip

This report is designed like the Fall Catalog report in the XtraReports Demos. You can use the demo report to get implementation details.

Design a Report with Charts

The report below visualizes grouped data from the Products table in a chart. The group header band’s Band.PageBreak property is set to Before the Band. The report’s XtraReport.Landscape property is set to true.

MergeReports_Chart_DesignTime

MergeReports_Chart

Merge Reports by Alternating Pages

Implement a function that creates report documents and combines them by alternating between pages that contain charts and ones that contain tables.

using DevExpress.XtraReports.UI;
// ...

private XtraReport MergeTwoReports() {
    // Create the 1st report and generate its document.
    XtraReport1 report1 = new XtraReport1();
    report1.CreateDocument();

    // Create the 2nd report and generate its document.
    XtraReport2 report2 = new XtraReport2();
    report2.CreateDocument();

    // Merge the pages of two reports.
    int minPageCount = Math.Min(report1.Pages.Count, report2.Pages.Count);
    report1.ModifyDocument(x => {
        for (int i = 0; i < minPageCount; i++) {
            x.InsertPage(i * 2 + 1, report2.Pages[i]);
        };
        if (report2.Pages.Count != minPageCount) {
            for (int i = minPageCount; i < report2.Pages.Count; i++) {
                x.InsertPage(x.PageCount, report2.Pages[i]);
            }
        }
    });

    // Reset all page numbers in the resulting document.
    report1.PrintingSystem.ContinuousPageNumbering = true;

    return report1;
}

The combined report provides details on products belonging to a category and then illustrates product prices on a chart.

MergeReports_Table_Chart

Note

There are limitations when previewing merged reports.

Preview and Publish the Report

You can now preview the report. Refer to the following topics to learn how to do this in different platforms:

See Also