When I export a table to excel using ag-grid's own exportDataAsExcel()
the resulting excel contains dates as General data type instead of Date.
[]
I have used this:
exportDataAsExcel({
processCellCallback: ({col, val}) => {( /*date value formatting here*/ )}
})
to format both Date
, string
with proper date formatting (DD/MM/YYYY)
but I can't make excel properly recognize these cells as Date instead of General
This is reproducible with the excel export examples on their website: https://www.ag-grid.com/javascript-grid-excel/?framework=all#gsc.tab=0
I've used this code to apply value formatter in excell as well:
this.gridOptions.api.exportDataAsExcel({
processCellCallback: (params) => {
const colDef = params.column.getColDef()
// try to reuse valueFormatter from the colDef
if (colDef.valueFormatter) {
const valueFormatterParams: ValueFormatterParams = {
...params,
data: params.node.data,
node: params.node!,
colDef: params.column.getColDef()
};
return colDef.valueFormatter(valueFormatterParams);
}
return params.value;
},
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With