Reputation: 11
I tried setting the gridOptions of the grid like below. But while exporting the data through the export excel context menu, the file name is not considered. How can i set the file name while exporting the data through the export context menu of grid.
defaultExportParams: { fileName: "TestFileName" }
Upvotes: 1
Views: 5503
Reputation: 695
Try this code:
exportCsv() {
var excelParams = {
columnKeys: ['firstName', 'middleName','lastName', 'dob'],
allColumns: false,
fileName: 'Student List.csv',
skipHeader: false,
customHeader: 'Student List' + '\n',
customFooter: '\n \n Total No.Of Students :' + this.gridOptions.api.getModel().getRowCount() + ' \n'
}
this.gridOptions.api.exportDataAsCsv(excelParams);
}
Upvotes: 3