diff --git a/src/app/examples/grid-grouping.component.html b/src/app/examples/grid-grouping.component.html
index d658db709..5d53a9529 100644
--- a/src/app/examples/grid-grouping.component.html
+++ b/src/app/examples/grid-grouping.component.html
@@ -54,6 +54,8 @@
{{title}}
[gridOptions]="gridOptions"
(onGridBeforeExportToFile)="processing = true"
(onGridAfterExportToFile)="processing = false"
+ (onGridBeforeExportToExcel)="processing = true"
+ (onGridAfterExportToExcel)="processing = false"
(onAngularGridCreated)="angularGridReady($event)">
diff --git a/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts b/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts
index 7903430ee..4d43b551d 100644
--- a/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts
+++ b/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts
@@ -135,8 +135,8 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
@Output() onGridStateChanged = new EventEmitter();
@Output() onGridBeforeExportToFile = this.exportService.onGridBeforeExportToFile;
@Output() onGridAfterExportToFile = this.exportService.onGridAfterExportToFile;
- @Output() onGridBeforeExportToExcel = new Subject();
- @Output() onGridAfterExportToExcel = new Subject();
+ @Output() onGridBeforeExportToExcel = this.excelExportService.onGridBeforeExportToExcel;
+ @Output() onGridAfterExportToExcel = this.excelExportService.onGridAfterExportToExcel;
@Input() customDataView: any;
@Input() gridId: string;
@Input() gridOptions: GridOption;
@@ -339,10 +339,6 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
// if Excel Export is enabled, initialize the service with the necessary grid and other objects
if (this.gridOptions.enableExcelExport && this.sharedService) {
- // create an instance of the ExcelExportService only when required (opt-in)
- this.excelExportService = new ExcelExportService(this.translate);
- this.onGridBeforeExportToExcel = this.excelExportService.onGridBeforeExportToExcel;
- this.onGridAfterExportToExcel = this.excelExportService.onGridAfterExportToExcel;
this.excelExportService.init(this.grid, this.dataView);
}
diff --git a/src/app/modules/angular-slickgrid/services/excelExport.service.ts b/src/app/modules/angular-slickgrid/services/excelExport.service.ts
index 380ffa776..112389704 100644
--- a/src/app/modules/angular-slickgrid/services/excelExport.service.ts
+++ b/src/app/modules/angular-slickgrid/services/excelExport.service.ts
@@ -184,7 +184,7 @@ export class ExcelExportService {
// -----------------------
private getDataOutput(): string[][] | ExcelCellFormat[][] {
- const columns = this._grid.getColumns() || [];
+ const columns = this._grid && this._grid.getColumns && this._grid.getColumns() || [];
// data variable which will hold all the fields data of a row
const outputData = [];
@@ -228,7 +228,7 @@ export class ExcelExportService {
// get grouped column titles and if found, we will add a "Group by" column at the first column index
// if it's a CSV format, we'll escape the text in double quotes
- const grouping = this._dataView.getGrouping();
+ const grouping = this._dataView && this._dataView.getGrouping && this._dataView.getGrouping();
if (grouping && Array.isArray(grouping) && grouping.length > 0) {
this._hasGroupedItems = true;
return groupByColumnHeader;
@@ -274,7 +274,7 @@ export class ExcelExportService {
* Get all the grid row data and return that as an output string
*/
private pushAllGridRowDataToArray(originalDaraArray: string[][], columns: Column[]): string[][] | ExcelCellFormat[][] {
- const lineCount = this._dataView.getLength();
+ const lineCount = this._dataView && this._dataView.getLength && this._dataView.getLength();
// loop through all the grid rows of data
for (let rowNumber = 0; rowNumber < lineCount; rowNumber++) {