印刷時のドキュメント名を設定する方法は?
対象製品
ActiveReports for .NET 9.0J
詳細
Viewerコントロールの[印刷]ボタンや Printメソッドで印刷する時のドキュメント名は、PrinterクラスのDocumentNameプロパティによって設定できます。
具体的なコードは、レポートの形式によって異なります。以下の内容をご覧ください。
◆サンプルコード(C#)
なお、セクションレポートの場合、レポートの生成結果をRDF形式で保存したり、シリアライズすることが可能ですが、これらのファイル/データに印刷時のドキュメント名を含めることはできません。あらかじめご注意ください。
◆サンプルコード(C#)
具体的なコードは、レポートの形式によって異なります。以下の内容をご覧ください。
セクションレポートの場合
◆サンプルコード(VB.NET)Private Sub Form1_Load(...) Handles MyBase.Load
Dim rpt As New SectionReport1()
' 印刷時のドキュメント名を設定します。
rpt.Document.Printer.DocumentName = "文書1"
' ※Document.Nameプロパティでも設定可能です。
' rpt.Document.Name = "文書1"
' レポートを実行し、プレビューします。
rpt.Run(False)
Me.Viewer1.Document = rpt.Document
End Sub
Dim rpt As New SectionReport1()
' 印刷時のドキュメント名を設定します。
rpt.Document.Printer.DocumentName = "文書1"
' ※Document.Nameプロパティでも設定可能です。
' rpt.Document.Name = "文書1"
' レポートを実行し、プレビューします。
rpt.Run(False)
Me.Viewer1.Document = rpt.Document
End Sub
◆サンプルコード(C#)
private void Form1_Load(object sender, System.EventArgs e)
{
SectionReport1 rpt = new SectionReport1();
// 印刷時のドキュメント名を設定します。
rpt.Document.Printer.DocumentName = "文書1";
// ※Document.Nameプロパティでも設定可能です。
// rpt.Document.Name = "文書1";
// レポートを実行し、プレビューします。
rpt.Run(false);
this.viewer1.Document = rpt.Document;
}
{
SectionReport1 rpt = new SectionReport1();
// 印刷時のドキュメント名を設定します。
rpt.Document.Printer.DocumentName = "文書1";
// ※Document.Nameプロパティでも設定可能です。
// rpt.Document.Name = "文書1";
// レポートを実行し、プレビューします。
rpt.Run(false);
this.viewer1.Document = rpt.Document;
}
なお、セクションレポートの場合、レポートの生成結果をRDF形式で保存したり、シリアライズすることが可能ですが、これらのファイル/データに印刷時のドキュメント名を含めることはできません。あらかじめご注意ください。
ページレポート/RDLレポートの場合
◆サンプルコード(VB.NET)Private Sub Form1_Load(...) Handles MyBase.Load
Dim rpt As New GrapeCity.ActiveReports.PageReport()
rpt.Load(New System.IO.FileInfo("PageReport1.rdlx"))
Dim MyDocument As New GrapeCity.ActiveReports.Document.PageDocument(rpt)
' 印刷時のドキュメント名を設定します。
MyDocument.Printer.DocumentName = "文書1"
' レポートを実行し、プレビューします。
Me.Viewer1.LoadDocument(MyDocument)
End Sub
Dim rpt As New GrapeCity.ActiveReports.PageReport()
rpt.Load(New System.IO.FileInfo("PageReport1.rdlx"))
Dim MyDocument As New GrapeCity.ActiveReports.Document.PageDocument(rpt)
' 印刷時のドキュメント名を設定します。
MyDocument.Printer.DocumentName = "文書1"
' レポートを実行し、プレビューします。
Me.Viewer1.LoadDocument(MyDocument)
End Sub
◆サンプルコード(C#)
private void Form1_Load(object sender, System.EventArgs e)
{
GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport();
rpt.Load(new System.IO.FileInfo("PageReport1.rdlx"));
GrapeCity.ActiveReports.Document.PageDocument MyDocument
= new GrapeCity.ActiveReports.Document.PageDocument(rpt);
// 印刷時のドキュメント名を設定します。
MyDocument.Printer.DocumentName = "文章1";
// レポートを実行し、プレビューします。
this.viewer1.LoadDocument(MyDocument);
}
{
GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport();
rpt.Load(new System.IO.FileInfo("PageReport1.rdlx"));
GrapeCity.ActiveReports.Document.PageDocument MyDocument
= new GrapeCity.ActiveReports.Document.PageDocument(rpt);
// 印刷時のドキュメント名を設定します。
MyDocument.Printer.DocumentName = "文章1";
// レポートを実行し、プレビューします。
this.viewer1.LoadDocument(MyDocument);
}
関連情報
キーワード
HowTo 印刷・プレビュー