ActiveReports allows you to run multiple reports and combine their PagesCollections, or specified portions of them, into a single report. The document containing the merged reports can be saved to an RDF file or exported.
The Add method of the ActiveReports Document Pages Collection takes one parameter: value. The value parameter references a report document page. To add an entire report, use code like that in the example below to iterate through the entire pages collection of a report and append it to the first report.
The following example shows what the code for the Add() method looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste JUST ABOVE the Form Load event. |
Copy Code |
---|---|
Dim i As Integer |
Visual Basic.NET code. Paste INSIDE the Form Load event. |
Copy Code |
---|---|
Dim rpt As New rptOne() rpt.Run() Dim rpt2 As New rptTwo() rpt2.Run() For i = 0 To rpt2.Document.Pages.Count - 1 rpt.Document.Pages.Add(rpt2.Document.Pages(i)) Next Viewer1.Document = rpt.Document |
To write the code in C#
C# code. Paste JUST ABOVE the Form Load event. |
Copy Code |
---|---|
int i; |
C# code. Paste INSIDE the Form Load event. |
Copy Code |
---|---|
rptOne rpt = new rptOne(); rpt.Run(); rptTwo rpt2 = new rptTwo(); rpt2.Run(); for(i = 0; i < rpt2.Document.Pages.Count; i++) { rpt.Document.Pages.Add(rpt2.Document.Pages[i]); } viewer1.Document = rpt.Document; |
The AddRange method has two overloads, each with one parameter. The first overload takes an array of page objects, while the second takes a pages collection. Use the second overload to add an entire report's pages collection. Us the first (as in the example below) to append only specified pages from the second report onto the first.
The following example shows what the code for the AddRange() method looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Form Load event. |
Copy Code |
---|---|
Dim rpt As New rptOne() rpt.Run() Dim rpt2 As New rptTwo() rpt2.Run() rpt.Document.Pages.AddRange(New Page() {rpt2.Document.Pages(0), rpt2.Document.Pages(1)}) Viewer1.Document = rpt.Document |
To write the code in C#
C# code. Paste INSIDE the Form Load event. |
Copy Code |
---|---|
rptOne rpt = new rptOne(); rpt.Run(); rptTwo rpt2 = new rptTwo(); rpt2.Run(); rpt.Document.Pages.AddRange(new Page[] {rpt2.Document.Pages[0],rpt2.Document.Pages[1]} ); viewer1.Document = rpt.Document; |
The Insert method takes two parameters, an index, which dictates where in the main report the pages are inserted, and value, the report page to insert.
The following example shows what the code for the Insert method looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Form Load event. |
Copy Code |
---|---|
Dim rpt As New rptInsertPage() rpt.Run() Dim rpt2 As New rptCoverPage() rpt2.Run() rpt.Document.Pages.Insert(1, rpt2.Document.Pages(0)) Viewer1.Document = rpt.Document |
To write the code in C#
C# code. Paste INSIDE the Form Load event. |
Copy Code |
---|---|
rptInsertPage rpt = new rptInsertPage(); rpt.Run(); rptCoverPage rpt2 = new rptCoverPage(); rpt2.Run(); rpt.Document.Pages.Insert(1, rpt2.Document.Pages[0]); viewer1.Document = rpt.Document; |
The InsertNew method takes one parameter, index, which specifies the page after which you want to insert a new blank page.
The following example shows what the code for the InsertNew() method looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Form Load event. |
Copy Code |
---|---|
Dim rpt As New rptInsertPage() rpt.Run() rpt.Document.Pages.InsertNew(3) Viewer1.Document = rpt.Document |
To write the code in C#
C# code. Paste INSIDE the Form Load event. |
Copy Code |
---|---|
rptInsertPage rpt = new rptInsertPage(); rpt.Run(); rpt.Document.Pages.InsertNew(3); viewer1.Document = rpt.Document; |