Raj GK
Raj GK

Reputation: 21

How to specify the sheet name in Excel Export (NOT file name) - Ag-Grid

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

Answers (2)

nihal kazi
nihal kazi

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

Jarod Moser
Jarod Moser

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

Related Questions