尝试使用 cellValue= worksheet.getRow(1).getCell(1).value;
和 cellValue=console.log(worksheet.getCell('A1'))
请在我的代码下面找到:
cellread2=function(){
var Excel;
var filePath = path.resolve(__dirname,'E:/excel.xlsx');
if (typeof require !== 'undefined') {
Excel = require('C:/Users/user/AppData/Roaming/npm/node_modules/exceljs/dist/exceljs');
}
var wb = new Excel.Workbook();
console.log(wb);
wb.xlsx.readFile(filePath);
var worksheet = wb.getWorksheet('Sheet1');
//cellValue= worksheet.getRow(1).getCell(1).value;//Error :TypeError: Cannot read property 'getRow' of undefined
cellValue=console.log(worksheet.getCell('A1'))// TypeError: Cannot read property 'getCell' of undefined
console.log(cellValue);
}