美文网首页
SheetJS导入xlsx文件数据不完整

SheetJS导入xlsx文件数据不完整

作者: 王家薪 | 来源:发表于2023-12-01 16:24 被阅读0次

https://docs.sheetjs.com/docs/miscellany/errors
某些第三方编写器工具不会更新 XLSX 或 XLS 或 XLSB 导出中的尺寸记录。SheetJS 实用函数将跳过不在范围内的值。
以下辅助函数将重新计算范围:

function update_sheet_range(ws) {
  var range = {s:{r:Infinity, c:Infinity},e:{r:0,c:0}};
  Object.keys(ws).filter(function(x) { return x.charAt(0) != "!"; }).map(XLSX.utils.decode_cell).forEach(function(x) {
    range.s.c = Math.min(range.s.c, x.c); range.s.r = Math.min(range.s.r, x.r);
    range.e.c = Math.max(range.e.c, x.c); range.e.r = Math.max(range.e.r, x.r);
  });
  ws['!ref'] = XLSX.utils.encode_range(range);
}

相关文章

网友评论

      本文标题:SheetJS导入xlsx文件数据不完整

      本文链接:https://www.haomeiwen.com/subject/vomcgdtx.html