ExcelJS with Angular and Typescript
See original GitHub issueI’m working on integrating ExcelJS into a browser based node.js client built using the angular framework and typescript (and grunt). I previously tested the library in a separate project and was able to get it working using grunt with browserify, but this required me to bundle my own app.js script with a ‘require’ on the exceljs dependency.
My current project is designed to reference minified libraries by declaring script tags in index.html, and type definitions in a separate typings folder. I’ve done both for exceljs, but when I attempt to run my code (which declares a new Workbook via new Excel.Workbook()), I get the following error:
ReferenceError: Can't find variable: Excel in app/src/myScript.js (line 56)
Also Note: When I try and add a require statement on exceljs in the file that needs it, I get another ReferenceError:
ReferenceError: Can't find variable: require
What steps am I missing in integrating the library such that Excel will be recognized as the correct namespace? Or is there another way I should be declaring a Workbook?
Issue Analytics
- State:
- Created 6 years ago
- Comments:13
Top GitHub Comments
I have found a workaround for no type definitions:
As long as you just use the import from
exceljs
for type definitions and only use functions from the import fromexceljs/dist/exceljs.min.js
, the app will run just fine and you still get type safety.In which way you import exceljs?
I use ExcelJs in Angular (4) and TS too, with the following import:
import * as Excel from 'exceljs';
after that, you can use Exceljs:
const myWorkbook = new Excel.Workbook();