|
262 | 262 | * @propertyOf ui.grid.exporter.api:GridOptions
|
263 | 263 | * @description The default filename to use when saving the downloaded excel, only used in IE (other browsers open excels in a new window)
|
264 | 264 | * <br/>Defaults to 'download.xlsx'
|
| 265 | + * <pre> |
| 266 | + * gridOptions.exporterExcelFilename = "rows.xlsx" |
| 267 | + * </pre> |
| 268 | + * <br/>Or a function returning a string: |
| 269 | + * <pre> |
| 270 | + * gridOptions.exporterExcelFilename = function(grid, rowTypes, colTypes) { return "rows" + rowTypes + ".xlsx" }; |
| 271 | + * </pre> |
265 | 272 | */
|
266 | 273 | gridOptions.exporterExcelFilename = gridOptions.exporterExcelFilename ? gridOptions.exporterExcelFilename : 'download.xlsx';
|
267 | 274 |
|
|
271 | 278 | * @propertyOf ui.grid.exporter.api:GridOptions
|
272 | 279 | * @description The default sheetname to use when saving the downloaded to excel
|
273 | 280 | * <br/>Defaults to 'Sheet1'
|
| 281 | + * <pre> |
| 282 | + * gridOptions.exporterExcelSheetName = "HitListSheet" |
| 283 | + * </pre> |
| 284 | + * <br/>Or a function returning a string: |
| 285 | + * <pre> |
| 286 | + * gridOptions.exporterExcelSheetName = function(grid, rowTypes, colTypes) { return "HitListSheet" + rowTypes }; |
| 287 | + * </pre> |
274 | 288 | */
|
275 | 289 | gridOptions.exporterExcelSheetName = gridOptions.exporterExcelSheetName ? gridOptions.exporterExcelSheetName : 'Sheet1';
|
276 | 290 |
|
|
1624 | 1638 | this.loadAllDataIfNeeded(grid, rowTypes, colTypes).then(function() {
|
1625 | 1639 | var exportColumnHeaders = grid.options.showHeader ? self.getColumnHeaders(grid, colTypes) : [];
|
1626 | 1640 |
|
1627 |
| - var workbook = new ExcelBuilder.Workbook(); |
1628 |
| - var aName = grid.options.exporterExcelSheetName ? grid.options.exporterExcelSheetName : 'Sheet1'; |
| 1641 | + var aName = 'Sheet1'; |
| 1642 | + if (grid.options.exporterExcelSheetName) { |
| 1643 | + aName = angular.isFunction(grid.options.exporterExcelSheetName) ? grid.options.exporterExcelSheetName(grid, rowTypes, colTypes) : grid.options.exporterExcelSheetName; |
| 1644 | + } |
| 1645 | + |
1629 | 1646 | var sheet = new ExcelBuilder.Worksheet({name: aName});
|
| 1647 | + var workbook = new ExcelBuilder.Workbook(); |
1630 | 1648 | workbook.addWorksheet(sheet);
|
1631 | 1649 | var docDefinition = self.prepareAsExcel(grid, workbook, sheet);
|
1632 | 1650 |
|
|
1649 | 1667 | sheet.setData(sheet.data.concat(excelContent));
|
1650 | 1668 |
|
1651 | 1669 | ExcelBuilder.Builder.createFile(workbook, {type: 'blob'}).then(function(result) {
|
1652 |
| - self.downloadFile (grid.options.exporterExcelFilename, result, grid.options.exporterCsvColumnSeparator, |
1653 |
| - grid.options.exporterOlderExcelCompatibility); |
| 1670 | + var fileName = angular.isFunction(grid.options.exporterExcelFilename) ? grid.options.exporterExcelFilename(grid, rowTypes, colTypes) : grid.options.exporterExcelFilename; |
| 1671 | + self.downloadFile(fileName, result, grid.options.exporterCsvColumnSeparator, grid.options.exporterOlderExcelCompatibility); |
1654 | 1672 | });
|
1655 | 1673 | });
|
1656 | 1674 | }
|
|
0 commit comments