轉(zhuǎn)帖|使用教程|編輯:鮑佳佳|2020-07-15 15:18:37.530|閱讀 609 次
概述:本篇文章主要介紹了ActiveReports報(bào)表打印常用功能,以幫助您快速入門,下面我們將從以下幾個(gè)方面進(jìn)行介紹:PDF打印、在JS Viewer中打印,打印方法,高級(jí)打印選項(xiàng)。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
ActiveReports是一款專注于.NET和.NET Core 平臺(tái)的報(bào)表控件。通過拖拽式報(bào)表設(shè)計(jì)器,可以快速地設(shè)計(jì)Excel表格、Word文檔、圖表、數(shù)據(jù)過濾、數(shù)據(jù)鉆取、精準(zhǔn)套打等類型報(bào)表,全面滿足 WinForm、ASP.NET、ASP.NET MVC、WPF 平臺(tái)中各種報(bào)表的開發(fā)需要。同時(shí),通過豐富的 API 可以靈活的實(shí)現(xiàn)報(bào)表創(chuàng)建、加載和運(yùn)行時(shí)的個(gè)性化自定義需求。
本篇文章主要介紹了ActiveReports報(bào)表打印常用功能,以幫助您快速入門,下面我們將從以下幾個(gè)方面進(jìn)行介紹:PDF打印、在JS Viewer中打印,打印方法,高級(jí)打印選項(xiàng)。
為了節(jié)省每次打印PDF文檔時(shí)的工作量,可以在將報(bào)告導(dǎo)出為PDF格式時(shí)預(yù)設(shè)基本打印選項(xiàng)。
注意:打印預(yù)設(shè)屬性僅在Professional Edition許可證中可用。與Standard Edition License一起使用時(shí),將顯示評(píng)估在“頁面/ RDL”和“部分”報(bào)告中,都可以使用“導(dǎo)出”對(duì)話框或通過代碼設(shè)置“ PDF打印預(yù)設(shè)”屬性。 PDF打印預(yù)設(shè)屬性在以下查看器的“導(dǎo)出”對(duì)話框中可用。
Standalone Designer End-User Designer Web Viewer WPF Viewer
使用“導(dǎo)出”;對(duì)話框設(shè)置PDF打印預(yù)設(shè)
1、打開導(dǎo)出對(duì)話框。
2、在“導(dǎo)出”對(duì)話框的“導(dǎo)出格式”字段中,選擇“便攜式文檔格式(PDF)”。
3、展開“打印預(yù)設(shè)”選項(xiàng),并設(shè)置打印預(yù)設(shè)的必需屬性。
4、單擊“確定”關(guān)閉對(duì)話框。
注意:這些屬性在1.7或更高版本的PDF中可用。PDF版本1.6支持PageScaling屬性。
1、從Visual Studio的"文件"菜單中,選擇"新建",然后選擇"項(xiàng)目"。
2、在出現(xiàn)的"新建項(xiàng)目"對(duì)話框中,在VB.NET或C#語言下,單擊"報(bào)告"節(jié)點(diǎn)。
3、選擇要添加的報(bào)表應(yīng)用程序的類型:
ActiveReports 14 Page Report Application ActiveReports 14 RDL Report Application ActiveReports 14 Section Report Application (xml-based)
4、在“名稱”字段中,輸入報(bào)表應(yīng)用程序的名稱,然后單擊“確定”。 所選的報(bào)告類型將添加到您的項(xiàng)目中。
5、在設(shè)計(jì)視圖中,雙擊表單標(biāo)題欄以創(chuàng)建Form_Load事件。
6、添加以下代碼以調(diào)用Export方法并在Form_Load事件中設(shè)置打印預(yù)設(shè)。
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報(bào)表
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");
本文轉(zhuǎn)自葡萄城
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: