用途

.xlsx在浏览器或 Node.js中读取中小型文件。使用严格的模式解析为 JSON 解析一个30k+行的文件时可能会抛出一个RangeError: Maximum call stack size exceeded. 因此,要读取庞大的数据集,请改用xlsxpackage 之类的东西。该库适用于读取中小型.xlsx文件。

安装或引入

  1. npm install read-excel-file --save
  1. import readXlsxFile from 'read-excel-file'

use

Browser【excel 转json文件】

  1. <input type="file" id="input" />
  1. import readXlsxFile from 'read-excel-file'
  2. const input = document.getElementById('input')
  3. input.addEventListener('change', () => {
  4. readXlsxFile(input.files[0]).then((rows) => {
  5. // `rows` is an array of rows
  6. // each row being an array of cells.
  7. })
  8. })

具体用法参考官方文档