ActiveReports 报表打印方法汇总

ActiveReports 提供了多种打印报表的方法和功能,本文主要总结了ActiveReports提供的报表打印的所有方法,可以通过这些方法来实现报表打印或套打

发布于 2016/06/29 00:00

ActiveReports

 

ActiveReports 提供了多种打印报表的方法和功能,本文主要总结了ActiveReports提供的报表打印的所有方法,可以通过这些方法来实现报表打印或套打:

1. 使用Viewer 提供的Viewer.Print 方法

2. 使用SectionDocumnet 或PageDocument 提供的 Print 方法

3. 使用PrintExtension 类提供的Print 方法。

Viewer.Print()方法

在Viewer 控件中可以调用Viewer类提供的Print 方法来打印报表,需要保证打印报表之前,报表已经存在

以下代码描述了如何使用Viewer控件的Print方法。

VB 代码:

Viewer1.Print(True, True, True)

 

C# 代码:

viewer1.Print(true, true, true);

 

Document 提供的Print方法

SectionDocument 和PageDocument 都提供了直接打印报表Document对象的方法,以下代码展示了如何使用Document对象提供的Print方法。

SectionReport

VB 代码:

Imports GrapeCity.ActiveReports
Dim rpt = New SectionReport1()
rpt.Run(False)
Dim sectionDocument = rpt.Document
sectionDocument.Print(True, True, False)

 

C#代码:

//引入命名空间
using GrapeCity.ActiveReports;
//生成报表对象
var rpt = new SectionReport1();
rpt.Run(false);
var sectionDocument = rpt.Document;
//打印报表
sectionDocument.Print(true, true, false);

 

 

PageReport(注页面报表和RDL 报表在代码层上都是PageReport对象)

VB 代码:

Imports GrapeCity.ActiveReports
Dim file_name As String = "..\..\PageReport1.rdlx"
Dim pageReport As New GrapeCity.ActiveReports.PageReport(New System.IO.FileInfo(file_name))
Dim pageDocument As New GrapeCity.ActiveReports.Document.PageDocument(pageReport)
pageDocument.Print(True, True, False)

 

C#代码:

using GrapeCity.ActiveReports;
string file_name = @"..\..\PageReport1.rdlx";
GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(file_name));
GrapeCity.ActiveReports.Document.PageDocument pageDocument = new GrapeCity.ActiveReports.Document.PageDocument(pageReport);
pageDocument.Print(true, true, false);

 

调用 PrintExtensions 类提供的Print方法

注意:PrintExtension.Print方法是以拓展方式实现的打印方法,主要包含在GrapeCity.ActiveReports.Viewer.Win.v10 的命名空间中,随意要使用PrintExtension.Print 方法需要将该dll引用到项目中。

SectionReport

VB 代码:

GrapeCity.ActiveReports.PrintExtension.Print(sectionDocument, True, True)

 

 

C# 代码:

GrapeCity.ActiveReports.PrintExtension.Print(sectionDocument, true, true);

 

Page Report

VB代码:

GrapeCity.ActiveReports.PrintExtension.Print(pageDocument, True, True)

 

C#代码:

GrapeCity.ActiveReports.PrintExtension.Print(pageDocument, true, true);

 

 

您在使用产品过程中有任何疑问,可以登录葡萄城开发者社区和经验丰富的技术工程师、ActiveReports开发人员交流:了解更多

了解ActiveReports产品更多特性:

/developer/activereports

下载产品体验产品功能:

/download/?pid=16

ActiveReports 报表控件| 下载试用

ActiveReports 是一款专注于 .NET 平台的报表控件,全面满足 HTML5 / WinForm / ASP.NET / ASP.NET MVC / WPF 等平台下报表设计和开发工作需求,作为专业的报表工具为全球超过 300,000 开发人员提供了全面的报表开发服务。

您对ActiveReports产品的任何技术问题,都有技术支持工程师提供1对1专业解答,点击此处即可发帖提问>>技术支持论坛

相关产品
推荐相关案例
关注微信
葡萄城社区二维码

关注“葡萄城社区”

加微信获取技术资讯

加微信获取技术资讯

想了解更多信息,请联系我们, 随时掌握技术资源和产品动态