I managed to get it work using this approach (Angular-CLI):
npm install file-saver --save
npm install @types/file-saver --save
After that import Filesaver in component:
import * as FileSaver from 'file-saver';
And you can use it like this:
let blob = new Blob([document.getElementById('exportDiv').innerHTML], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-16le"
});
FileSaver.saveAs(blob, "export.xls");
As you can see, you don't have to add anything in angular-cli.json. Just install library and it's types, import it and you are ready to go.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…