我有一个excel,它有多张表。现在我想得到每张纸的行数
var XLSX = require('xlsx');
var workbook = XLSX.readFile('test.xlsx');
var sheet_name_list = workbook.SheetNames;
let count = [];
for (var sheetIndex = 0; sheetIndex < sheet_name_list.length; sheetIndex++) {
var worksheet = workbook.Sheets[sheet_name_list[sheetIndex]];
var range = XLSX.utils.decode_range(worksheet['!ref']);
var num_rows = range.e.r - range.s.r + 1;
count.push({
data_count: num_rows
});
}
return count;
通过使用上面的脚本,我得到了最大65536,即使excel有100000的记录。
尝试更改:
var range = XLSX.utils.decode_range(worksheet['!ref']);
至:
var range = XLSX.utils.decode_range(worksheet['!fullref']);