ActiveReports 10
Rendering to Excel
ActiveReports 10 > ActiveReports User Guide > Concepts > Exporting > Rendering Extensions > Rendering to Excel

Microsoft Excel is one of the formats to which you can render your report using ExcelRenderingExtension. You can export excel files in two formats, i.e. Xls and Xlsx.

In order to render your report to Excel, add reference to the following assemblies in the project:   

The following steps provide an example of rendering a report in the Microsoft Excel format.

  1. In Visual Studio, create a new WindowsForms application or open an existing one.
  2. On the Form.cs or Form.vb that opens, double-click the title bar to create the Form_Load event.
  3. Add the following code inside the Form_Load event.
    Visual Basic.NET code. Paste INSIDE the Form Load event.
    Copy Code
    ' Provide the page report you want to render.
    Dim report As New GrapeCity.ActiveReports.PageReport(New System.IO.FileInfo("C:\Sample_PageReport.rdlx"))
    Dim reportDocument As New GrapeCity.ActiveReports.Document.PageDocument(report)
    
    ' Create an output directory
    Dim outputDirectory As New System.IO.DirectoryInfo("C:\MyExcel")
    outputDirectory.Create()
    
    ' Provide settings for your rendering output.
    Dim excelSetting As New GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings()
    excelSetting.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.FileFormat.Xls
    Dim setting As GrapeCity.ActiveReports.Extensibility.Rendering.ISettings = excelSetting
    
    ' Set the rendering extension and render the report.
    Dim excelRenderingExtension As New GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension()
    Dim outputProvider As New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name))
    reportDocument.Render(excelRenderingExtension, outputProvider, excelSetting.GetSettings())
    
    C# code. Paste INSIDE the Form Load event.
    Copy Code
    // Provide the page report you want to render.
    GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(@"C:\Sample_PageReport.rdlx"));
    GrapeCity.ActiveReports.Document.PageDocument reportDocument = new GrapeCity.ActiveReports.Document.PageDocument(report);
    
    // Create an output directory
    System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyExcel");
    outputDirectory.Create();
    
    // Provide settings for your rendering output.
    GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings excelSetting = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings();
    excelSetting.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.FileFormat.Xls;
    GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = excelSetting;
    
    //Set the rendering extension and render the report.
    GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension excelRenderingExtension = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension();
    GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
    reportDocument.Render(excelRenderingExtension, outputProvider, excelSetting.GetSettings());
    

Excel Rendering Properties

ActiveReports offers several options to control how reports render to Microsoft Excel.

Property Description
PageSettings Returns an ExcelRenderingExtensionPageSettings object for initializing Excel file print setting.
Pagination Forces pagination or galley report layout mode.
Security Returns an ExcelRenderingExtensionSecurity object for initializing document security.
UseDefaultPalette Indicates whether to export the document with the default Excel palette.
FileFormat Specifies the output format of the Excel document, i.e. Xls or Xlsx.
OpenXmlStandard

Specifies the level of Open XML document conformance on exporting in Xlsx file format. You can choose between following values:

Strict

The default value.

Transitional

The Excel file generated by scheduled task execution using Strict (the default value of OpenXMLStandard) cannot be viewed on IOS devices. To change the default value of OpenXMLStandard, add following configuration settings in GrapeCity.ActiveReports.config file:
<ReportingConfiguration>
  <Extensions>
    <Render>
      <Extension Name="Excel" Type="GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension, GrapeCity.ActiveReports.Export.Excel.v10, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" >
        <Settings>
          <Property Name="OpenXmlStandard" Value="Transitional" Type="GrapeCity.ActiveReports.Export.Excel.Page.OpenXmlStandard, GrapeCity.ActiveReports.Export.Excel.v10, Culture=neutral, PublicKeyToken=cc4967777c49a3ff"/>
        </Settings>
      </Extension>
    </Render>
  </Extensions>
</ReportingConfiguration>

MultiSheet Indicates whether to generate a single-sheet or multi-sheet Excel document.

 

Interactivity

Reports rendered in Excel support a number of interactive features like Bookmarks and Hyperlinks. However, in case you have any data hidden at the time of rendering (like in a drill-down report), it does not show up in the output. It is recommended that you expand all toggle items prior to rendering.

Limitations

See Also

Concepts