React Data Grid

Excel Export - Excel Tables

react logo
Enterprise

Excel Export provides a way to export grid data as an Excel table, which would instantly enable the user to filter, sort, and analyse the data in Excel. You can instruct AG Grid to automatically create an Excel table containing the grid data when exporting to Excel.

Exporting Excel Tables

In order to create an Excel table for the exported data, you should set the exportAsExcelTable property in the ExcelExportParams configuration object. Excel config parameters can either be set in the defaultExcelExportParams Grid Option or passed as an argument to one of the Excel export API methods.

const defaultExcelExportParams = useMemo(() => { 
	return {
        exportAsExcelTable: true,
     };
}, []);

<AgGridReact defaultExcelExportParams={defaultExcelExportParams} />

The exported Excel file will contain a sheet with a table enclosing the exported data. When you select a cell within the table, the Table tab in the Excel tabs toolbar will appear, which provides options to filter, sort, and analyse the data.

This is how the exported Excel file with Table looks when opened in Excel:

Exporting a Sheet as Excel Table

The following example demonstrates how to export the grid data as an Excel table.

  • We set the exportAsExcelTable property to true in the defaultExcelExportParams Grid Option.

Proceed as follows to see the Excel table:

  • You can trigger the export by clicking the Export to Excel button or via context menu.
  • Once your file is exported, open it in Excel and select a cell within the table to see the Table tab.
  • This example includes grouped columns, and thus only the leaf columns are included in the Excel table.
  • In this example, only Athlete, and Country columns can be filtered. This is also reflected in the Excel table.

Customisation

You can customise the Excel table by providing a config object instead of a boolean value for the exportAsExcelTable. This config object can contain the following properties: