轉帖|使用教程|編輯:鮑佳佳|2020-07-15 15:18:37.530|閱讀 609 次
概述:本篇文章主要介紹了ActiveReports報表打印常用功能,以幫助您快速入門,下面我們將從以下幾個方面進行介紹:PDF打印、在JS Viewer中打印,打印方法,高級打印選項。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
ActiveReports是一款專注于.NET和.NET Core 平臺的報表控件。通過拖拽式報表設計器,可以快速地設計Excel表格、Word文檔、圖表、數據過濾、數據鉆取、精準套打等類型報表,全面滿足 WinForm、ASP.NET、ASP.NET MVC、WPF 平臺中各種報表的開發需要。同時,通過豐富的 API 可以靈活的實現報表創建、加載和運行時的個性化自定義需求。
本篇文章主要介紹了ActiveReports報表打印常用功能,以幫助您快速入門,下面我們將從以下幾個方面進行介紹:PDF打印、在JS Viewer中打印,打印方法,高級打印選項。
為了節省每次打印PDF文檔時的工作量,可以在將報告導出為PDF格式時預設基本打印選項。
注意:打印預設屬性僅在Professional Edition許可證中可用。與Standard Edition License一起使用時,將顯示評估在“頁面/ RDL”和“部分”報告中,都可以使用“導出”對話框或通過代碼設置“ PDF打印預設”屬性。 PDF打印預設屬性在以下查看器的“導出”對話框中可用。
Standalone Designer End-User Designer Web Viewer WPF Viewer
使用“導出”;對話框設置PDF打印預設
1、打開導出對話框。
2、在“導出”對話框的“導出格式”字段中,選擇“便攜式文檔格式(PDF)”。
3、展開“打印預設”選項,并設置打印預設的必需屬性。
4、單擊“確定”關閉對話框。
注意:這些屬性在1.7或更高版本的PDF中可用。PDF版本1.6支持PageScaling屬性。
1、從Visual Studio的"文件"菜單中,選擇"新建",然后選擇"項目"。
2、在出現的"新建項目"對話框中,在VB.NET或C#語言下,單擊"報告"節點。
3、選擇要添加的報表應用程序的類型:
ActiveReports 14 Page Report Application ActiveReports 14 RDL Report Application ActiveReports 14 Section Report Application (xml-based)
4、在“名稱”字段中,輸入報表應用程序的名稱,然后單擊“確定”。 所選的報告類型將添加到您的項目中。
5、在設計視圖中,雙擊表單標題欄以創建Form_Load事件。
6、添加以下代碼以調用Export方法并在Form_Load事件中設置打印預設。
Visual Basic.NET代碼粘貼到Form_Load事件中
Dim sectionReport As New GrapeCity.ActiveReports.SectionReport() Dim xtr As New System.Xml.XmlTextReader(Application.StartupPath + "\..\..\SectionReport1.rpx") sectionReport.LoadLayout(xtr) sectionReport.Run() 'Define settings for PDF Dim p As New GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport() p.Version = GrapeCity.ActiveReports.Export.Pdf.Section.PdfVersion.Pdf17 'Set default print settings using PrintPresets class p.PrintPresets.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None p.PrintPresets.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge p.PrintPresets.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two p.PrintPresets.PaperSourceByPageSize = True p.PrintPresets.PrintPageRange = "1-3" p.Export(sectionReport.Document, Application.StartupPath + "\PrintPresets.pdf")
C#代碼。 粘貼到Form_Load事件中
GrapeCity.ActiveReports.SectionReport sectionReport = new GrapeCity.ActiveReports.SectionReport(); System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Application.StartupPath + @"\..\..\SectionReport1.rpx"); sectionReport.LoadLayout(xtr); sectionReport.Run(); //Define settings for PDF GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport p = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport(); p.Version = GrapeCity.ActiveReports.Export.Pdf.Section.PdfVersion.Pdf17; //Set default print settings using PrintPresets class p.PrintPresets.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None; p.PrintPresets.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge; p.PrintPresets.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two; p.PrintPresets.PaperSourceByPageSize = true; p.PrintPresets.PrintPageRange = "1-3"; p.Export(sectionReport.Document, Application.StartupPath + "\\PrintPresets.pdf");
頁面/RDL報表
Visual Basic.NET代碼。 粘貼到Form_Load事件中
'Set the rendering extension and render the report. Dim pdfExport = New GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension() 'Define settings for PDF Dim pdfSettings As New GrapeCity.ActiveReports.Export.Pdf.Page.Settings() pdfSettings.Version = GrapeCity.ActiveReports.Export.Pdf.Page.PdfVersion.Pdf17 pdfSettings.PrintOnOpen = True 'Set default print settings using PrintPresets class Dim pdfPresetsSetting As New GrapeCity.ActiveReports.Export.Pdf.PrintPresets() pdfPresetsSetting.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None pdfPresetsSetting.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge pdfPresetsSetting.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two pdfPresetsSetting.PaperSourceByPageSize = True pdfPresetsSetting.PrintPageRange = "1-3" pdfSettings.PrintPresets = pdfPresetsSetting Dim outputFile = New IO.FileInfo("..\..\PrintPresets.pdf") Dim reportFile = New IO.FileInfo("..\..\PageReport1.rdlx") Dim fileStreamProvider = New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputFile.Directory, Path.GetFileNameWithoutExtension(outputFile.FullName)) Using pageDocument = New GrapeCity.ActiveReports.PageReport(reportFile).Document pageDocument.Render(pdfExport, fileStreamProvider, pdfSettings) End Using
C#代碼。 粘貼到Form_Load事件中
GrapeCity.ActiveReports.SectionReport sectionReport = new GrapeCity.ActiveReports.SectionReport(); System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Application.StartupPath + @"\..\..\SectionReport1.rpx"); sectionReport.LoadLayout(xtr); sectionReport.Run(); //Define settings for PDF GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport p = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport(); p.Version = GrapeCity.ActiveReports.Export.Pdf.Section.PdfVersion.Pdf17; //Set default print settings using PrintPresets class p.PrintPresets.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None; p.PrintPresets.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge; p.PrintPresets.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two; p.PrintPresets.PaperSourceByPageSize = true; p.PrintPresets.PrintPageRange = "1-3"; p.Export(sectionReport.Document, Application.StartupPath + "\\PrintPresets.pdf");
本文轉自葡萄城
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: