exceljs: Angular Material crashes

Hello all,

I’m trying to use this lib with Angular 8 and Angular Materia, and below is my method

async exportExcel(jsonData: any[], headers: TableColumn[], fileName: string, config?: ExcelRowConfiguration  ) {
    // create workbook and worksheet
    let workbook = new Workbook();
    let worksheet = workbook.addWorksheet(fileName);

    if (!config) {
      config = new ExcelRowConfiguration();
    }

    //config.fonts = excel title config
    //config.alignment = excel header config
    this.generateFileTitle(fileName, worksheet, config);
    this.generateHeaderRow(headers, worksheet, config);
    this.generateDataRows(jsonData, worksheet, headers);
    await this.generateExcelFile(workbook, fileName);
  }

For some reason when the code is like above, my material components acquire stranger behaviors. For example: I click to open a mat-expansion-panel and it expands only if I click in other area, I have to click twice to export table, and other stranger behaviors. But when I comment the method’s body everything work fine. Is known any issue with Angular Material Components and ExcelJS?

About this issue

Most upvoted comments

Ok so far i’ ve changed my pollyfills.ts like this:


import 'exceljs'; // will be removed in Angular 8 > & excejs > 4.0.0
import 'zone.js/dist/zone';  // Included with Angular CLI.

After i’ ve upgraded both Angular & exceljs i’ ll remove this exceljs import & make the module lazy load again.

For now i hope to it’ ll work like this.

Thank you all.

I cannot reproduce this error anymore on v4.1.1

Inside lib/exceljs.browser.js is a line:

require('core-js/modules/es.promise');

Inside this module is something that causes this problem. I do not really have the time do pinpoint the location. But it does not seem to be a problem in this library. And the code still works if I remove it, so I leave it so someone else to find a better solution for this bug.