作成日: 2023/01/26 最終更新日: 2023/01/26
文書種別
使用方法
詳細
MultiSheetプロパティを"True"に設定することで、レポートの各ページを個別のExcelシートとしてエクスポートすることが可能です。
ただし、シートに分けて出力できるのはレポートのページ単位となります。
任意のタイミングや、グループごとに分けることはできません。
セクションレポートの場合
◆サンプルコード (C#)
//using ステートメントを追加します using GrapeCity.ActiveReports.Export.Excel.Section; //レポートを作成します。 SectionReport1 sectionReport = new SectionReport1(); sectionReport.Run(); //エクスポートの各種設定を行います。 XlsExport ExcelExport1 = new XlsExport(); ExcelExport1.FileFormat = FileFormat.Xlsx; ExcelExport1.MultiSheet = true; //レポートをエクスポートします。 ExcelExport1.Export(sectionReport.Document, @"C:\MyExcel\セクションレポート.xlsx");
◆サンプルコード (VB.NET)
' Imports ステートメントを追加します。 Imports GrapeCity.ActiveReports.Export.Excel.Section ' レポートを作成します。 Dim sectionReport As New SectionReport1 sectionReport.Run() ' エクスポートの各種設定を行います。 Dim ExcelExport1 As New XlsExport ExcelExport1.FileFormat = FileFormat.Xlsx ExcelExport1.MultiSheet = True ' レポートをエクスポートします。 ExcelExport1.Export(sectionReport.Document, "C:\MyExcel\セクションレポート.xlsx")
ページレポート/RDLレポートの場合
◆サンプルコード (C#)
//using ステートメントを追加します。 using GrapeCity.ActiveReports; using GrapeCity.ActiveReports.Export.Excel.Page; using GrapeCity.ActiveReports.Rendering.IO; using System.IO; //レポートを作成します。 string file_name = "PageReport1.rdlx"; PageReport pageReport = new PageReport(new FileInfo(file_name)); // ディレクトリを指定します。 DirectoryInfo outputDirectory = new DirectoryInfo(@"C:\MyExcel"); // エクスポートの各種設定を行います。 ExcelRenderingExtensionSettings excelSetting = new ExcelRenderingExtensionSettings(); excelSetting.FileFormat = FileFormat.Xlsx; excelSetting.MultiSheet = true; // RenderingExtensionを使用し、レポートをエクスポートします。 ExcelRenderingExtension excelRenderingExtension = new ExcelRenderingExtension(); var outputProvider = new FileStreamProvider(outputDirectory, "ページレポート"); pageReport.Document.Render(excelRenderingExtension, outputProvider, excelSetting.GetSettings());
◆サンプルコード (VB.NET)
' Imports ステートメントを追加します。 Imports GrapeCity.ActiveReports Imports GrapeCity.ActiveReports.Export.Excel.Page Imports GrapeCity.ActiveReports.Rendering.IO Imports System.IO ' レポートを作成します。 Dim file_name As String = "PageReport1.rdlx" Dim pageReport As New PageReport(New FileInfo(file_name)) ' ディレクトリを指定します。 Dim outputDirectory As New DirectoryInfo("C:\MyExcel") ' エクスポートの各種設定を行います。 Dim excelSetting As New ExcelRenderingExtensionSettings() excelSetting.FileFormat = FileFormat.Xls excelSetting.MultiSheet = True ' RenderingExtensionを使用し、レポートをエクスポートします。 Dim excelRenderingExtension As New ExcelRenderingExtension() Dim outputProvider As New FileStreamProvider(outputDirectory, "ページレポート") pageReport.Document.Render(excelRenderingExtension, outputProvider, excelSetting.GetSettings())