[英]Angular 5 and ExcelJS
I have been trying to use and following the examples from this library: https://www.npmjs.com/package/exceljs#create-a-workbook 我一直在尝试使用并遵循该库中的示例: https : //www.npmjs.com/package/exceljs#create-a-workbook
I am using it on Angular 5. I always get an error 我在Angular 5上使用它。总是出现错误
graceful-fs.js:166 Uncaught TypeError: Cannot read property 'prototype' of undefined
at patch (graceful-fs.js:166)
From these lines of my code: 从我的代码的这些行:
import * as Excel from 'exceljs';
export class ExcelHandler {
public testExcelJs() {
var workBook: Excel.Workbook;
var workSheet: Excel.Worksheet;
workBook = new Excel.Workbook();
workSheet = workBook.addWorksheet(sheetName);
}
}
Thanks. 谢谢。
Seems the npm example is given in node definitions and you are using typescript, a quick workaround would be to install node types so that you needn't find equivalent typescript syntax everytime, ie npm install --save-dev @types/node
, with this done, node definitions would be added to the IDE and would also resolve compilation issues. 似乎npm示例在节点定义中给出,并且您正在使用typescript,一种快速的解决方法是安装节点类型,这样您就不必每次都找到等效的typescript语法,即
npm install --save-dev @types/node
,使用完成此操作后,节点定义将被添加到IDE中,并且还将解决编译问题。
Now your file could be like this: 现在您的文件可能是这样的:
var Excel = require('exceljs');
export class ExcelHandler {
public testExcelJs() {
var workBook = new Excel.Workbook();
var workSheet = workBook.addWorksheet('my-worksheet');
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.