I add context menu and reassign export to csv and Excel - I need export use valueFormatter for some column.
Export working fine, but after I run export to xml, and then run export to Excel - I get xml file.
It's happen only here - because I use getContextMenuItems. Other tables uses standard context menu working fine.
menu:
getContextMenuItems = (() => {
const self = this;
return (param) => {
const menu = [
'copy',
'copyWithHeaders',
'paste',
'separator',
{
name: 'Export',
subMenu: [
{
name: 'csvExport',
action: () => {
self.gridApi.exportDataAsCsv({
processCellCallback: (params) => {
if (params.column.getColDef().valueFormatter) {
const valueFormatterParams: ValueFormatterParams = {
...params,
data: params.node.data,
// tslint:disable-next-line:no-non-null-assertion
node: params.node!,
colDef: params.column.getColDef()
};
return params.column.getColDef().valueFormatter(valueFormatterParams);
}
return params.value;
},
});
}
},
{
name: 'excelExport',
action: () => {
self.gridApi.exportDataAsExcel({
processCellCallback: (params) => {
if (params.column.getColDef().valueFormatter) {
const valueFormatterParams: ValueFormatterParams = {
...params,
data: params.node.data,
// tslint:disable-next-line:no-non-null-assertion
node: params.node!,
colDef: params.column.getColDef()
};
return params.column.getColDef().valueFormatter(valueFormatterParams);
}
return params.value;
},
});
}
},
'excelXmlExport'
]
}
];
return menu;
};
})();
Plunker for example: https://plnkr.co/edit/ysaS5IJzOwvVacRb
- run export to Excel (formated) - get xlsx
- run export to xml - get xml
- run export to Excel (formated) - get xml instead xlsx