Visual Studioプロジェクトにレポートテンプレートを追加する方法を説明します。
プロジェクトにActiveReportsを追加する
- [プロジェクト]メニュー(または[Web サイト]メニュー)-[新しい項目の追加]をクリックします。
- 以下のレポートテンプレートのいずれかを選択します。レポートテンプレートの詳細は、「レポートの種類」を参照してください。
- ActiveReports 9.0J セクションレポート(コード)
- ActiveReports 9.0J セクションレポート(XML)
- ActiveReports 9.0J ページレポート(XML)
- ActiveReports 9.0J RDLレポート(XML)
- [名前]ボックスに任意のレポート名を入力し、[追加]ボタンをクリックします。
プロジェクトに選択した種類のレポートテンプレートが追加され、レポートデザイナが表示されます。
 |
メモ:GrapeCity.ActiveReports.Viewer.Win.v9.dllは、レポートレイアウトを追加した際にプロジェクトに自動で追加されません。Viewerコントロールをフォームに配置するか、アセンブリの参照を追加する必要があります。 |
実行時にプロジェクトにActiveReportsを追加する
- Visual Studioで新しいWindowsフォームアプリケーションを作成するか、既存のアプリケーションを開きます。
- Visual Studioのツールボックスから、ActiveReportsビューワコントロールをフォーム上にドラッグします。
- ビューワコントロールのDockプロパティをFillに設定します。
- Form.csまたはForm.vbが開いたら、タイトルバーをダブルクリックしてForm_Loadのハンドラを作成します。
- 以下のコードをForm_Loadイベント内に追加します。
ページレポート
Visual Basicコード(Form Loadイベント内に貼り付けます。) |
コードのコピー
|
' ページレポートの新しいインスタンスを作成します。
Dim pageReport As New GrapeCity.ActiveReports.PageReport()
Dim Page As New GrapeCity.ActiveReports.PageReportModel.Page()
Dim fixedPage As New GrapeCity.ActiveReports.PageReportModel.FixedPage()
' ページレポートにテキストボックスを追加します。
Dim textbox1 As New GrapeCity.ActiveReports.PageReportModel.TextBox()
textbox1.Name = "TextBox1"
textbox1.Height = "1cm"
textbox1.Width = "10cm"
textbox1.Left = "2cm"
textbox1.Top = "0.5cm"
textbox1.Value = "ページレポート"
Page.ReportItems.Add(textbox1)
fixedPage.Pages.Add(Page)
pageReport.Report.Body.ReportItems.Add(fixedPage)
' ページドキュメントを作成して、ビューワにロードします。
Dim pageDocument As New GrapeCity.ActiveReports.Document.PageDocument(pageReport)
viewer1.LoadDocument(pageDocument)
|
C#(Form_Loadイベント内に貼り付けます) |
コードのコピー
|
// ページレポートの新しいインスタンスを作成します。
GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport();
GrapeCity.ActiveReports.PageReportModel.Page Page = new GrapeCity.ActiveReports.PageReportModel.Page();
GrapeCity.ActiveReports.PageReportModel.FixedPage fixedPage = new GrapeCity.ActiveReports.PageReportModel.FixedPage();
// ページレポートにテキストボックスを追加します。
GrapeCity.ActiveReports.PageReportModel.TextBox textbox1 = new GrapeCity.ActiveReports.PageReportModel.TextBox();
textbox1.Name = "TextBox1";
textbox1.Height = "1cm";
textbox1.Width = "10cm";
textbox1.Left = "2cm";
textbox1.Top = "0.5cm";
textbox1.Value = "ページレポート";
Page.ReportItems.Add(textbox1);
fixedPage.Pages.Add(Page);
pageReport.Report.Body.ReportItems.Add(fixedPage);
// ページドキュメントを作成して、ビューワにロードします。
GrapeCity.ActiveReports.Document.PageDocument pageDocument = new GrapeCity.ActiveReports.Document.PageDocument(pageReport);
viewer1.LoadDocument(pageDocument);
|
RDLレポート
Visual Basicコード(Form Loadイベント内に貼り付けます。) |
コードのコピー
|
' RDLレポートの新しいインスタンスを作成します。
Dim rdlReport As New GrapeCity.ActiveReports.PageReport()
' RDLレポートにテキストボックスを追加します。
Dim textbox1 As New GrapeCity.ActiveReports.PageReportModel.TextBox()
textbox1.Name = "TextBox1"
textbox1.Height = "1cm"
textbox1.Width = "10cm"
textbox1.Left = "2cm"
textbox1.Top = "0.5cm"
textbox1.Value = "RDLレポート"
rdlReport.Report.Body.ReportItems.Add(textbox1)
' ページドキュメントを作成して、ビューワにロードします。
Dim rdlDocument As New GrapeCity.ActiveReports.Document.PageDocument(rdlReport)
viewer1.LoadDocument(rdlDocument)
|
C#(Form_Loadイベント内に貼り付けます) |
コードのコピー
|
// RDLレポートの新しいインスタンスを作成します。
GrapeCity.ActiveReports.PageReport rdlReport = new GrapeCity.ActiveReports.PageReport();
// RDLレポートにテキストボックスを追加します。
GrapeCity.ActiveReports.PageReportModel.TextBox textbox1 = new GrapeCity.ActiveReports.PageReportModel.TextBox();
textbox1.Name = "TextBox1";
textbox1.Height = "1cm";
textbox1.Width = "10cm";
textbox1.Left = "2cm";
textbox1.Top = "0.5cm";
textbox1.Value = "RDLレポート";
rdlReport.Report.Body.ReportItems.Add(textbox1);
// ページドキュメントを作成して、ビューワにロードします。
GrapeCity.ActiveReports.Document.PageDocument rdlDocument = new GrapeCity.ActiveReports.Document.PageDocument(rdlReport);
viewer1.LoadDocument(rdlDocument);
|
セクションレポート
Visual Basicコード(Form Loadイベント内に貼り付けます。) |
コードのコピー
|
' セクションレポートの新しいインスタンスを作成します。
Dim sectionReport As New GrapeCity.ActiveReports.SectionReport()
' 詳細のセクションを作成します。
sectionReport.Sections.Add(GrapeCity.ActiveReports.Document.Section.SectionType.Detail, "Body")
' セクションレポートにテキストボックスを追加します。
Dim textbox1 As New GrapeCity.ActiveReports.SectionReportModel.TextBox()
textbox1.Name = "TextBox1"
textbox1.Height = 1.5F
textbox1.Width = 10.0F
textbox1.Left = 0.5F
textbox1.Top = 0.5F
textbox1.Value = "セクションレポート"
sectionReport.Sections(0).Controls.Add(textbox1)
' セクションレポートをビューワにロードします。
sectionReport.Run()
viewer1.LoadDocument(sectionReport)
|
C#(Form_Loadイベント内に貼り付けます) |
コードのコピー
|
// セクションレポートの新しいインスタンスを作成します。
GrapeCity.ActiveReports.SectionReport sectionReport = new GrapeCity.ActiveReports.SectionReport();
// 詳細のセクションを作成します。
sectionReport.Sections.Add(GrapeCity.ActiveReports.Document.Section.SectionType.Detail, "Body");
// セクションレポートにテキストボックスを追加します。
GrapeCity.ActiveReports.SectionReportModel.TextBox textbox1 = new GrapeCity.ActiveReports.SectionReportModel.TextBox();
textbox1.Name = "TextBox1";
textbox1.Height = 1.5F;
textbox1.Width = 10F;
textbox1.Left = 0.5F;
textbox1.Top = 0.5F;
textbox1.Value = "セクションレポート";
sectionReport.Sections[0].Controls.Add(textbox1);
// セクションレポートをビューワにロードします。
sectionReport.Run();
viewer1.LoadDocument(sectionReport);
|
関連トピック