ActiveReports 18 .NET Edition
Developers / Export Reports / Export Section Reports / Excel Export
In This Topic
    Excel Export
    In This Topic

    XLSX is a format that opens in Microsoft Excel as a spreadsheet. This export does not render reports exactly as they appear in the Viewer due to inherent differences in the formats. The XLSX export filter has a number of useful properties that allow you to control your output. You can set the properties either in code using the XLSExport object after adding reference to MESCIUS.ActiveReports.Export.Excel package in your project.

    The Excel export now supports the CrossPlatform compatibility mode.

    Excel Export Properties

    Property Valid Values Description
    AutoRowHeight True or False (default) Set to True to have Excel set the height of rows based on the contents. Otherwise XlsExport calculates the height of rows. In some cases this may make the output look better inside Excel. However, a value of True may adversely affect pagination when printing, as it may stretch the height of the page.
    DisplayGridLines True (default) or False Set to False to hide grid lines in Excel.
    FileFormat Xls97Plus (default) or Xls95 or Xlsx

    Set to Xls95 to use Microsoft Excel 95, Xls95Plus to use Microsoft Excel 97and Xlsx to use Microsoft Excel 2007 or newer.

    MinColumnWidth Single (VB) or float (C#)

    Set the number of inches that is the smallest width for a column in the exported spreadsheet.

    Tip: Larger values reduce the number of empty columns in a sheet. Set this value to 1 inch or more to get rid of small empty columns.

    MinRowHeight Single (VB) or float (C#)

    Set the number of inches that is the smallest height for a row in the exported spreadsheet.

    Tip: Larger values force the export to place more controls on a single line by reducing the number of rows added to match blank space. Set this value to .25 inches or more to get rid of small empty rows.

    MultiSheet True or False (default)

    Set to True to export each page of your report to a separate sheet within the Excel file. This can increase performance and output quality at the cost of memory consumption for reports with complex pages and a lot of deviation between page layouts.

    In general, use False for reports with more than 30 pages.

    PageSettings

    Set a print orientation and paper size of Excel sheet.
    RemoveVerticalSpace True or False (default) Set to True to remove vertical empty spaces from the spreadsheet. This may improve pagination for printing.
    Security Set a password and username to protect the excel spreadsheet.
    UseCellMerging True or False (default) Set to True to merge cells where applicable.
    UseDefaultPalette True or False (default) Set to True to export document with Excel default palette.

    Excel Export usage and limitations

    Usage:

    Does not support:

    Export Report using Excel Export Filter

    Use the following steps to export reports through Excel export filters.

    1. Create a new or open an existing Visual Studio project.
      • If you are creating a new project,
        - select ActiveReports 18 Section Report (xml-based) Application in Create a New Project dialog, and then
        - specify a name for the project, and click OK.
      • If you are using an existing project,
        - go to the Solution Explorer and right-click the project and select Add > New Item, and then
        - select ActiveReports 18 Section Report (xml-based) and click Add.
    2. Add a reference to MESCIUS.ActiveReports.Export.Excel package in the project. See Manage ActiveReports Dependencies for more information.
    3. In your project's Bin>Debug folder, place the report.rpx (Section Report).    
    4. On the Form.cs or Form.vb, double-click the title bar to create the Form_Load event.
    5. In Form_Load event, add the following code to export Section Reports .
      Visual Basic.NETcode. Paste INSIDE the Form_Load event
      Copy Code
      ' Create a Section report.
      Dim rpt As New GrapeCity.ActiveReports.SectionReport()
      
      ' For the code to work, report.rpx must be placed in the bin\debug folder of your project.
      Dim xtr As New System.Xml.XmlTextReader(Application.StartupPath + "\report.rpx")
      rpt.LoadLayout(xtr)
      rpt.Run()
                         
      ' Export the report in Excel format.
      Dim XlsExport1 As New GrapeCity.ActiveReports.Export.Excel.Section.XlsExport()
      
      ' Set a file format of the exported excel file to Xlsx to support Microsoft Excel 2007 and newer versions.
      XlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx
      XlsExport1.Export(rpt.Document, Application.StartupPath + "\XLSExpt.xlsx")
      

      C# code. Paste INSIDE the Form_Load event.
      Copy Code
      // Create a Section Report
      GrapeCity.ActiveReports.SectionReport rpt = new GrapeCity.ActiveReports.SectionReport();
      
      // For the code to work, report.rpx must be placed in the bin\debug folder of your project.
      System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Application.StartupPath + "\\report.rpx");
      rpt.LoadLayout(xtr);
      rpt.Run();
      
      // Export the report in XLSX format.
      GrapeCity.ActiveReports.Export.Excel.Section.XlsExport XlsExport1 = new GrapeCity.ActiveReports.Export.Excel.Section.XlsExport();
      
      // Set a file format of the exported excel file to Xlsx to support Microsoft Excel 2007 and newer versions.
      XlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx;
      XlsExport1.Export(rpt.Document, Application.StartupPath + "\\XLSExpt.xlsx");