The grid cell and row group values exported to Excel can be customised using the following function params for a call to exportDataAsExcel
API method or in the defaultExcelExportParams
.
gridApi.exportDataAsExcel({
processCellCallback(params) {
const value = params.value
return value === undefined ? '' : `_${value}_`
},
processRowGroupCallback(params) {
return `row group: ${params.node.key}`
}
})
See below the functions on the ExcelExportParams
interface to customise exported grid cell and row group values.
Note that it is also possible to format the values by Using the Value Formatter for Export.
The following example shows Excel customisations where the exported document has the following:
row group:
_
, unless they are undefined
, in which case they are emptyRow group column cells are also cells. This means that each row group column cell will first have the processRowGroupCallback
invoked for it, and then the returned value will have processCellCallback
invoked for it. This is why exported row group cell values will have the _
surrounding the value, which is applied by the processCellCallback
.
When using row grouping while hiding open parents (groupHideOpenParents=true
), export to Excel doesn't export the group rows as collapsible groups in Excel. Instead, all exported rows are on the same level and cannot be expanded/collapsed in Excel.
The column headers and group headers exported to Excel can be customised using the following function params for a call to exportDataAsExcel
API method or in the defaultExcelExportParams
.
gridApi.exportDataAsExcel({
processGroupHeaderCallback(params) {
return `group header: ${params.columnApi.getDisplayNameForColumnGroup(params.columnGroup, null)}`
},
processHeaderCallback(params) {
return `header: ${params.columnApi.getDisplayNameForColumn(params.column, null)}`
}
});
See below the functions on the ExcelExportParams
interface to customise exported column group headers and headers.
The following example shows Excel customisations where the exported document has the following:
group header:
header:
Continue to the next section: Images.