Exceljs: Using the browser version in Typescript

Created on 4 May 2017  路  3Comments  路  Source: exceljs/exceljs

I would really, really love to use this in Typescript but after several hours of futile effort, I am giving up and finding another, probably less capable, package that I can run in the browser and work with from Typescript. Guys, a trivial example of how to do this would be enormously helpful. What is really frustrating is that this is obviously very close to working but either I am clueless or some trivial example is needed. I am not the first to fall thru this crack.

Most helpful comment

I used this method (presented in #335)

In project tree:
npm install exceljs --save

In the component.ts:
import * as ExcelJs from 'exceljs/dist/exceljs.min.js';

Do not try to do dependency injection into constructor() (it requires proper .d.ts). Instead just grab the ExcelJs:

var workbook = new ExcelJs.Workbook();

Works for me.

P.S. When I was trying var workbook = new ExcelJs.Workbook(); with import ExcelJs from 'exceljs;, app crashed.

All 3 comments

Ok, to make this easier for the next person,

1) after npm installing exceljs

2) use the following import:

import * as ExcelJs from 'exceljs/lib/exceljs.browser.js';

See #238 - I made a type definition file for it, but still a WIP, so not put into a PR yet...

I used this method (presented in #335)

In project tree:
npm install exceljs --save

In the component.ts:
import * as ExcelJs from 'exceljs/dist/exceljs.min.js';

Do not try to do dependency injection into constructor() (it requires proper .d.ts). Instead just grab the ExcelJs:

var workbook = new ExcelJs.Workbook();

Works for me.

P.S. When I was trying var workbook = new ExcelJs.Workbook(); with import ExcelJs from 'exceljs;, app crashed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dcrystalj picture dcrystalj  路  3Comments

miniil picture miniil  路  4Comments

MR4online picture MR4online  路  3Comments

kurt343 picture kurt343  路  3Comments

nandakumardtc picture nandakumardtc  路  3Comments