xtrareports-3320-feature-guide-to-devexpress-reports-merge-reports.md
Complex reports can be a combination of several simple reports, pages, or ranges. The following help topics describe how to merge reports:
You can create pages in a separate report and merge them into the base report. You can print or export the merged pages as a single document and keep the original page settings and orientation.
private void 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 pages of two reports, page-by-page.
int minPageCount = Math.Min(report1.Pages.Count, report2.Pages.Count);
for (int i = 0; i < minPageCount; i++) {
report1.Pages.Insert(i * 2 + 1, report2.Pages[i]);
}
if (report2.Pages.Count != minPageCount) {
for (int i = minPageCount; i < report2.Pages.Count; i++) {
report1.Pages.Add(report2.Pages[i]);
}
}
// Reset all page numbers in the resulting document.
report1.PrintingSystem.ContinuousPageNumbering = true;
// Show the Print Preview form.
report1.ShowPreviewDialog();
}
Private Sub MergeTwoReports()
' Create the 1st report and generate its document.
Dim report1 As New XtraReport1()
report1.CreateDocument()
' Create the 2nd report and generate its document.
Dim report2 As New XtraReport2()
report2.CreateDocument()
' Merge pages of two reports, page-by-page.
Dim minPageCount As Integer = Math.Min(report1.Pages.Count, report2.Pages.Count)
For i As Integer = 0 To minPageCount - 1
report1.Pages.Insert(i * 2 + 1, report2.Pages(i))
Next i
If report2.Pages.Count <> minPageCount Then
For i As Integer = minPageCount To report2.Pages.Count - 1
report1.Pages.Add(report2.Pages(i))
Next i
End If
' Reset all page numbers in the resulting document.
report1.PrintingSystem.ContinuousPageNumbering = True
' Show the Print Preview form.
report1.ShowPreviewDialog()
End Sub
Complex reports can also be constructed based on several data sources or data tables. For more information, review the following help topics:
Tutorials that explain how to use this functionality in EUD Report Designers for WinForms and Web are included in the End-User Documentation online help section: