Excel Export provides a way to export an Excel file with multiple sheets. This can be useful when you need to export data from different grids into a single Excel file.
Exporting the grid into different sheets follows a specific process:
getSheetDataForExcel
method on a grid instance to get the data exported for a specific sheet.exportMultipleSheetsAsExcel
or getMultipleSheetsAsExcel
methods to package them in a single Excel workbook.When using modules, the exportMultipleSheetsAsExcel
and getMultipleSheetsAsExcel
functions can be imported directly from the excel-export
module as import { exportMultipleSheetsAsExcel, getMultipleSheetsAsExcel } from '@ag-grid-enterprise/excel-export'
.
Calling getSheetDataForExcel
starts a Multiple Sheet export process, that can only be ended by calling the exportMultipleSheetsAsExcel
or getMultipleSheetsAsExcel
methods. Until one of these two methods is called to complete the process, no data can be exported from the grid using exportDataAsExcel
or getDataAsExcel
.
In this example, we use the onlySelected=true
property to segment the grid data into multiple sheets, each containing 100 data rows.
Note the following:
sheetName
, they will be named ag-grid
, ag-grid_1
, ag-grid_2
and so on.In this example, we filter on the sport column to segment the grid data into multiple sheets, each containing all the data for a specific sport value.
Note the following:
In this example, we export two grids, each into a separate sheet of the same Excel file. Drag a few rows from the grid on the left into the grid on the right and click the export button above the grid.
Note the following:
Athletes
grid will be exported to the Athletes
sheet.Selected Athletes
grid will be exported to the Selected Athletes
sheet.onExcelExport
method is relevant to Excel Exportget | This is method to be used to get the grid's data as a sheet, that will later be exported either by getMultipleSheetsAsExcel() or exportMultipleSheetsAsExcel() . |
export | Downloads an Excel export of multiple sheets in one file. |
get | Similar to exportMultipleSheetsAsExcel , except instead of downloading a file, it will return a Blob to be processed by the user. |
Continue to the next section: Rows.