本示例阐明了使用 XtraReport.Pages 属性来解决不同的任务。
下面的代码演示了如何把一个报表的所有页面添加到另一个报表的尾部。
C# | 复制代码 |
---|
private void CombineTwoReports() {
XtraReport1 report1 = new XtraReport1();
report1.CreateDocument();
XtraReport2 report2 = new XtraReport2();
report2.CreateDocument();
report1.Pages.AddRange(report2.Pages);
report1.PrintingSystem.ContinuousPageNumbering = true;
report1.ShowPreviewDialog();
}
|
Visual Basic | 复制代码 |
---|
Private Sub CombineTwoReports()
Dim report1 As XtraReport1 = New XtraReport1()
report1.CreateDocument()
Dim report2 As XtraReport2 = New XtraReport2()
report2.CreateDocument()
report1.Pages.AddRange(report2.Pages)
report1.PrintingSystem.ContinuousPageNumbering = True
report1.ShowPreviewDialog()
End Sub
|
下面的代码演示了如何把两个报表的页面逐页合并到一个报表中。
C# | 复制代码 |
---|
private void MergeTwoReports() {
XtraReport1 report1 = new XtraReport1();
report1.CreateDocument();
XtraReport2 report2 = new XtraReport2();
report2.CreateDocument();
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]);
}
}
report1.PrintingSystem.ContinuousPageNumbering = true;
report1.ShowPreviewDialog();
}
|
Visual Basic | 复制代码 |
---|
Private Sub MergeTwoReports()
Dim report1 As XtraReport1 = New XtraReport1()
report1.CreateDocument()
Dim report2 As XtraReport2 = New XtraReport2()
report2.CreateDocument()
Dim minPageCount As Integer = Math.Min(report1.Pages.Count, report2.Pages.Count)
Dim i As Integer = 0
Do While i < minPageCount
report1.Pages.Insert(i * 2 + 1, report2.Pages(i))
i += 1
Loop
If report2.Pages.Count <> minPageCount Then
i = minPageCount
Do While i < report2.Pages.Count
report1.Pages.Add(report2.Pages(i))
i += 1
Loop
End If
report1.PrintingSystem.ContinuousPageNumbering = True
report1.ShowPreviewDialog()
End Sub
|
下面的代码演示了如何重新排列报表页的顺序,以便于可以被打印为一个手册 (第一页、最后一页、第二页、倒数第二页、第三页等)。
C# | 复制代码 |
---|
private void CreateBooklet() {
XtraReport1 report1 = new XtraReport1();
report1.CreateDocument();
report1.PrintingSystem.ContinuousPageNumbering = false;
int centerPageIndex = Convert.ToInt32((report1.Pages.Count - 1) / 2);
for (int i = 0; i < centerPageIndex; i++) {
report1.Pages.Insert(i * 2 + 1, report1.Pages[report1.Pages.Count - 1]);
}
report1.ShowPreviewDialog();
}
|
Visual Basic | 复制代码 |
---|
Private Sub CreateBooklet()
Dim report1 As XtraReport1 = New XtraReport1()
report1.CreateDocument()
report1.PrintingSystem.ContinuousPageNumbering = False
Dim centerPageIndex As Integer = Convert.ToInt32((report1.Pages.Count - 1) / 2)
Dim i As Integer = 0
Do While i < centerPageIndex
report1.Pages.Insert(i * 2 + 1, report1.Pages(report1.Pages.Count - 1))
i += 1
Loop
report1.ShowPreviewDialog()
End Sub
|
参阅