作成日: 2023/09/19 最終更新日: 2023/09/19
文書種別
使用方法
詳細
アプリケーションの形態を問わず、Printメソッドでレポートを直接印刷できます。
※Webアプリの場合はサーバーサイドのプリンタが出力先になります。
Printメソッドを使用するための具体的な手順は以下の通りです。
-
NuGetパッケージをインストールする
NuGetパッケージマネージャーを使用してプロジェクトに以下のパッケージをインストールします。
NuGet Gallery | GrapeCity.ActiveReports.Viewer.Common.ja
PrintメソッドはGrapeCity.ActiveReports.Viewer.CommonアセンブリのGrapeCity.ActiveReports名前空間に実装されているため、このパッケージが必要になります。
-
名前空間をインポートする
印刷を実行するコードファイルの先頭に以下のコードを追加します。
◆サンプルコード (C#)
using GrapeCity.ActiveReports;
◆サンプルコード (VB.NET)
Imports GrapeCity.ActiveReports
-
SectionDocumentまたはPageDocumentからPrintメソッドを呼び出す
◆サンプルコード (C#)
// セクションレポート var sectionReport = new SectionReport1(); sectionReport.Run(); sectionReport.Document.Printer.PrinterName = "プリンタ名"; sectionReport.Document.Print(false, false, false); // ページレポート/RDLレポート var fi = new System.IO.FileInfo("PageReport1.rdlx"); var pageReport = new GrapeCity.ActiveReports.PageReport(fi); var settings = new GrapeCity.ActiveReports.PrinterSettings(); settings.Printer.PrinterName = "プリンタ名"; settings.ShowPrintDialog = false; settings.ShowPrintProgressDialog = false; settings.UsePrintingThread = false; pageReport.Document.Print(settings);
◆サンプルコード (VB.NET)
' セクションレポート Dim sectionReport = New SectionReport1() sectionReport.Run() sectionReport.Document.Printer.PrinterName = "プリンタ名" sectionReport.Document.Print(False, False, False) ' ページレポート/RDLレポート Dim fi = New System.IO.FileInfo("PageReport1.rdlx") Dim pageReport = New GrapeCity.ActiveReports.PageReport(fi) Dim settings = New GrapeCity.ActiveReports.PrinterSettings() settings.Printer.PrinterName = "プリンタ名" settings.ShowPrintDialog = False settings.ShowPrintProgressDialog = False settings.UsePrintingThread = False pageReport.Document.Print(settings)
Printメソッドの引数でダイアログの表示有無などを設定できます。
詳細な仕様は以下のリファレンスをご参照ください。
Print(SectionDocument,Boolean,Boolean,Boolean) メソッド
Print(PageDocument,PrinterSettings) メソッド