作成日: 2024/04/10 最終更新日: 2024/04/10
文書種別
使用方法
詳細
生成(Runメソッド実行)後のセクションレポートに、後付けで文字列や図形を描画したい場合、PagesコレクションのDrawTextやDrawLineなどのDraw***メソッドを使用します。
たとえば、複数のセクションレポートを合成してから全体を通したページ番号を描画したい場合、以下のようにDrawTextメソッドを使用することで実現可能です。
◆サンプルコード (C#)
SectionReport1 rpt1 = new SectionReport1(); //レポート1
SectionReport2 rpt2 = new SectionReport2(); //レポート2
// それぞれのレポートを作成します。
rpt1.Run(false);
rpt2.Run(false);
// レポート1にレポート2をマージします。
rpt1.Document.Pages.AddRange(rpt2.Document.Pages);
// レポートの下部にページ番号を描画します。
for (int i = 0; i < rpt1.Document.Pages.Count; i++)
{
rpt1.Document.Pages[i].Font = new Font("MS ゴシック", 10.5f);
rpt1.Document.Pages[i].ForeColor = Color.Black;
rpt1.Document.Pages[i].DrawText((i + 1).ToString(),
GrapeCity.ActiveReports.SectionReport.CmToInch(21.0f / 2.0f),
GrapeCity.ActiveReports.SectionReport.CmToInch(29.7f - 1.0f),
GrapeCity.ActiveReports.SectionReport.CmToInch(2.0f),
GrapeCity.ActiveReports.SectionReport.CmToInch(1.0f));
}
◆サンプルコード (VB.NET)
Dim rpt1 As New SectionReport1() ' レポート1
Dim rpt2 As New SectionReport2() ' レポート2
' それぞれのレポートを作成します。
rpt1.Run(False)
rpt2.Run(False)
' レポート1にレポート2をマージします。
rpt1.Document.Pages.AddRange(rpt2.Document.Pages)
' レポートの下部にページ番号を描画します。
For i As Integer = 0 To rpt1.Document.Pages.Count - 1
rpt1.Document.Pages(i).Font = New Font("MS ゴシック", 10.5)
rpt1.Document.Pages(i).ForeColor = Color.Black
rpt1.Document.Pages(i).DrawText((i + 1).ToString(),
GrapeCity.ActiveReports.SectionReport.CmToInch(21.0 / 2.0),
GrapeCity.ActiveReports.SectionReport.CmToInch(29.7 - 1.0),
GrapeCity.ActiveReports.SectionReport.CmToInch(2.0),
GrapeCity.ActiveReports.SectionReport.CmToInch(1.0))
Next
各メソッドの詳細については、クラスライブラリリファレンスをご確認ください。