彩票走势图

如何运用DevExpress XtraReports合并两个报表的页

原创|其它|编辑:郝浩|2012-09-20 11:25:38.000|阅读 2726 次

概述:分别演示了演示了如何在一个报表的末尾添加另一个报表的页面,如何一页页将两个报表的页面合并成一个单一报表和如何为报表页面重新排序,以便它可以被打印出来作为一个小册子(第一页,最后一页,第二页,倒数第二,第三页,等等)。附代码。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

下面的代码演示了DevExpress报表控件XtraReports如何在一个报表的末尾添加另一个报表的页面。

C#
private void CombineTwoReports() {
// 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();

// Add all pages of the 2nd report to the end of the 1st report.
report1.Pages.AddRange(report2.Pages);

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

// Show the Print Preview form.
report1.ShowPreviewDialog();
}
VB
Private Sub CombineTwoReports()
' Create the 1st report and generate its document.
Dim report1 As XtraReport1 = New XtraReport1()
report1.CreateDocument()

' Create the 2nd report and generate its document.
Dim report2 As XtraReport2 = New XtraReport2()
report2.CreateDocument()

' Add all pages of the 2nd report to the end of the 1st report.
report1.Pages.AddRange(report2.Pages)

' Reset all page numbers in the resulting document.
report1.PrintingSystem.ContinuousPageNumbering = True

' Show the Print Preview form.
report1.ShowPreviewDialog()
End Sub

下面的代码演示了如何一页页将两个报表的页面合并成一个单一报表。

C#
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();
}
VB
Private Sub MergeTwoReports()
' Create the 1st report and generate its document.
Dim report1 As XtraReport1 = New XtraReport1()
report1.CreateDocument()

' Create the 2nd report and generate its document.
Dim report2 As XtraReport2 = New XtraReport2()
report2.CreateDocument()

' Merge pages of two reports, page-by-page.
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

' Reset all page numbers in the resulting document.
report1.PrintingSystem.ContinuousPageNumbering = True

' Show the Print Preview form.
report1.ShowPreviewDialog()
End Sub
下面的代码演示了DevExpress报表控件XtraReports如何为报表页面重新排序,以便它可以被打印出来作为一个小册子(第一页,最后一页,第二页,倒数第二,第三页,等等)。
C#
private void CreateBooklet() {
// Create the 1st report and generate its document.
XtraReport1 report1 = new XtraReport1();
report1.CreateDocument();

// Preserve original page numbers on all pages.
report1.PrintingSystem.ContinuousPageNumbering = false;

// Create a booklet.
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]);
}

// Show the Print Preview form.
report1.ShowPreviewDialog();
}
VB
Private Sub CreateBooklet()
' Create the 1st report and generate its document.
Dim report1 As XtraReport1 = New XtraReport1()
report1.CreateDocument()

' Preserve original page numbers on all pages.
report1.PrintingSystem.ContinuousPageNumbering = False

' Create a booklet.
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

' Show the Print Preview form.
report1.ShowPreviewDialog()
End Sub



标签:DevExpress报表报表控件

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
相关产品
XtraReports Suite

针对Windows Forms、ASP.NET、ASP.NET MVC、WPF,Silverlight和LightSwitch开发者的下一代跨平台报表方案

DevExpress Universal Subscription

行业领先的界面控件开发包,帮助企业构建卓越应用!

DevExpress WPF Subscription

高效MVVM开发模式,WPF界面解决方案首选工具,帮助企业实现酷炫动效界面。

DevExpress Silverlight Controls

高性价比高实用性的Silverlight用户界面控件套包,拥有大量的示例和帮助文档,开发者能够快速上手!

DevExpress WinForms Subscription

为Windows Forms平台创建具有影响力的业务解决方案,高性价比WinForms界面控件套包。

title
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP