node 使用exceljs读取excel文件出错,提示file node found,哪位屌大的帮忙解决一下问题
下面是使用exceljs模块读取文件的代码
var workbook = new Excel.Workbook();
var filePath=path.join(__dirname, "./upload/"+new_excelname);
//console.log(filePath)
workbook.xlsx.readFile(filePath)
.then(function() {
// use workbook
// Iterate over all sheets
// Note: workbook.worksheets.forEach will still work but this is better
workbook.eachSheet(function(worksheet, sheetId) {
var worksheet = workbook.getWorksheet(0);
var rowCount=worksheet.rowCount;
var rowCount=worksheet.columnCount;
for(let i=0;i<rowCount;i++){
for( let j='A';j!=columnCount;j++){
res.send(j+'-'+i)
}
}
});
下面是错误提示
(node:60240) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: File not found: C:\Users\wenji\Desktop\njdcdss\upload\99800-2018-1-12-工 作簿1.xlsx
(node:60240) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
补充:文件确实在该路径下,且文件名无误
如果确定代码没问题,试试用英文做文件名