如何在 ActiveReports10 中实现报表拼接?

如何在 ActiveReports10 中实现报表拼接?

编码文章call10242025-07-19 22:08:443A+A-

报表拼接是我们处理报表文件中,容易遇到的问题。使用 ActiveReports10就可以实现将多个独立报表拼成一个整个大的报表,其中报表拼接的方法主要取决于报表类型。

下面,我们一起学习一下如何在 ActiveReports10 中实现报表拼接?

区域报表

区域报表由于它的组织结构的特殊性,有以下三种方法来实现拼接:

1. 添加或插入报表页

2. 覆盖报表页

3. 将报表保存成文档之后拼接报表

添加或插入报表页

在区域报表中,Document.Pages 属性(PageCollection 类)保存了报表生成的每一页。您可以执行添加,插入,赋值或删除报表页等操作,使用 PagesCollection 类提供的“Add”, ”AddRange”, ”CopyTo”, ”Insert”, ”InsertRange”, ”Remove”等。

实现代码:

//C#

// Run each report.

rpt1.Run(false);

rpt2.Run(false);

// Add the pages of rpt2 after rpt1.

for (int i = 0; i < rpt2.Document.Pages.Count; i++)

{

rpt1.Document.Pages.Add(rpt2.Document.Pages[i].Clone());

}

一旦拼接成功,可以在报表 Viewer 中显示报表了,设置打印布局可以指定打印设置,打印报表也可以选择逆向打印。

注意:区域报表只能与区域报表连接。

拼接报表页面

区域报表,可以使用 Page 的 Overlay 方法,将其他报表拼接到首个报表后面。

//C#

// Run each report.

rpt1.Run(false);

rpt2.Run(false);

// Overlay the first page of rpt2 onto each page of rpt1.

for (int i = 0; i < rpt1.Document.Pages.Count; i++)

{

rpt1.Document.Pages[i].Overlay(

(GrapeCity.ActiveReports.Document.Section.Page)

rpt2.Document.Pages[0].Clone());

}

一旦连接,就可以在报表 Viewer 中展示报表,导出并打印。

保存成 Document 对象时连接页面

// Specify paths to reports that were saved to RDF format.

string invoiceRdf = null;

invoiceRdf = Application.StartupPath.ToString() + “..\\..\\..\\Invoice.rdf”;

string letterRdf = null;

letterRdf = Application.StartupPath.ToString() + “..\\..\\..\\Letter.rdf”;

GrapeCity.ActiveReports.SectionReport merge = new GrapeCity.ActiveReports.SectionReport(); GrapeCity.ActiveReports.Document.SectionDocument fRdf = new GrapeCity.ActiveReports.Document.SectionDocument();

fRdf.Load(invoiceRdf);

merge.Document.Pages.AddRange(fRdf.Pages);

fRdf.Load(letterRdf);

for (int i = 0; i < = fRdf.Pages.Count – 1; i++)

{

merge.Document.Pages.Insert(i + 1, fRdf.Pages[i]);

i = i + 1;

}

页面和 RDL 报表

页面和 RDL 报表未提供报表连接的方法,但是有两种方法可用:

  • 将报表导出为 PDF 文件后,拼接。

  • 使用多页报表布局(仅限页面报表)

合并PDF文件

使用 PDF 渲染API将报表导出为 PDF 文件,导出成功后将多个 PDF 文件内容拼接。

使用多页布局

与连接报表不同,页面报表中使用不同数据控件来输出报表数据,当数据量过多时,可以自行换页展示。手动添加页就可以实现多页拼接。

以上就是在 ActiveReports10 中实现报表拼接的具体方法。

了解更多

参加视频会议,更快掌握ActiveReports报表工具!资深产品经理将详解 ActiveReports 报表功能、实操案例、技术资源等,您还可携带实际项目场景,和产品经理直接沟通,更快评估试用。

报名视频会议:
http://www.gcpowertools.com.cn/products/webinars.aspx

快人一步,免费试用

请通过以下方式联系葡萄城,获取 ActiveReports 的免费试用版:

微信:GrapeCityDT

邮件:marketing.xa@grapecity.com

官网:www.gcpowertools.com.cn

关于葡萄城控件

葡萄城是一家跨国软件研发集团,专注控件领域近30年,是全球最大的控件提供商,也是微软认证的金牌合作伙伴。

点击这里复制本文地址 以上内容由文彬编程网整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
qrcode

文彬编程网 © All Rights Reserved.  蜀ICP备2024111239号-4