ActiveReports 16 .NET Edition
ActiveReports 16 User Guide / Export Reports / Rendering Extensions / Rendering to Excel
In This Topic
    Rendering to Excel
    In This Topic

    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.

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

    1. Create a new Visual Studio project.
    2. In the New Project dialog that appears, select ActiveReports 16 Page Report Application and specify a name for the project in the Name field.
    3. Click OK to create a new ActiveReports 16 Page Report Application. By default a Page report is added to the project.
    4. Add reference to GrapeCity.ActiveReports.Export.Excel package in the project.
    5. On the Form.cs or Form.vb that opens, double-click the title bar to create the Form_Load event.
    6. 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()
      Dim reportDocument As New GrapeCity.ActiveReports.Document.PageDocument(report)
      ' Create an output directory.
      Dim outputDirectory As New System.IO.DirectoryInfo("C:\MyExcel")
      ' 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))
      ' Overwrite output file if it already exists.
      outputProvider.OverwriteOutputFile = True
      reportDocument.Render(excelRenderingExtension, outputProvider, setting.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();
      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");
      // 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));
      // Overwrite output file if it already exists.
      outputProvider.OverwriteOutputFile = true;
      reportDocument.Render(excelRenderingExtension, outputProvider, setting.GetSettings());

    Excel Rendering Properties

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

    Property Description
    Author Sets the name of the author that appears in the Author field in the Properties of the exported Excel document.
    Categories Sets the name of the categories that appears in the Categories field in the Properties of the exported Excel document.
    PageSettings Returns an ExcelRenderingExtensionPageSettings object for initializing Excel file print setting.
    Pagination Forces pagination or galley report layout mode.

    Shows direction of sheets from right to left.

    Security Returns an ExcelRenderingExtensionSecurity object for initializing document security.
    Title Sets the name of the title for a document that appears in the Title field in the Properties of the exported Excel document.
    UseCompression Indicates whether to use compression while exporting to the Xlsx file.
    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.

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

    • Transitional: The default value.
    • Strict: The Excel file generated using Strict cannot be viewed on iOS devices.
    MultiSheet Indicates whether to generate a single-sheet or multi-sheet Excel document.
    EnableToggles Allows to export collapsible rows in the detail and row groups of the Table control of an RDL report. This property gets displayed in the Export menu when the Pagination property is set to False.


    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.


    See Also