Monday, 31 August 2020

Upgrading to Angular 10 breaks ExcelJs

I have just upgraded my application from the last version of 9 to angular 10 using ng update. I know there are significant changes, and in the most part it has upgraded well, however I am currently getting an error from exceljs:

"export 'Workbook' (imported as 'Excel') was not found in 'exceljs/dist/exceljs'

Prior to the upgrade, it was using exceljs version 2.0.1. Now it is using exceljs 4.0.1. (It is one version prior to the latest version, because there is an error preventing compiling in the latest version due to an option argument being marked as required. That shouldn't matter.)

The import statement is as follows:

import * as Excel from "exceljs/dist/exceljs";

The code itself is pretty typical for exceljs. I have a service that provides data: HttpResponse and I load it into the workbook so that I can extract some of the columns.

this.myService.getMySpreadsheet().subscribe((data: HttpResponse<Blob>) => {
      new Response(data.body).arrayBuffer().then(arrayBuffer => {
        const wb: Excel.Workbook = new Excel.Workbook();
        wb.xlsx.load(arrayBuffer).then(() => {

          const ws1 = wb.getWorksheet("My Worksheet");

But it can't even get to that code now, because the angular compilation is broken.

Any idea how I can fix that problem? Is there some sort of backward compatibility flag that I need to add?



from Upgrading to Angular 10 breaks ExcelJs

No comments:

Post a Comment