Reputation: 21
When we export to excel in AgGrid, the default sheet name is ag-grid. How can I change it to another name?
Upvotes: 1
Views: 3244
Reputation: 31
const params = {
columnWidth: 100,
fileName: 'Your File Name',
sheetName:'Your Sheet Name'
};
this.gridApi.exportDataAsExcel(params);
You can pass params inside exportDataAsExcel()
function.
Upvotes: 3
Reputation: 7348
Yes, you can use the function getDataAsExcel(params)
to generate the XML, then parse through it for the Worksheet
element and change the ss:Name
attribute to whatever you want for your sheet name. It might be safe to just use str.replace
looking for 'ag-grid'
, but I am not certain on that.
Once that is done you just need to download the string/blob as a file.
Upvotes: 1