XLSX.utils.sheet_to_json解析excel

来源于 :https://www.cnblogs.com/zhenggaowei/p/11732314.html

 

// el-upload组件中绑定的changeFile
  function changeFile(file) {
    let f = file.raw;
    let reader = new FileReader();
    reader.readAsBinaryString(f);
    reader.onload = function (e) {
      let data = e.target.result;
      let wb = XLSX.read(data, { type: 'binary' });
      let json = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
      console.log(json)
    };
  };

  

posted @ 2022-01-25 10:52  苦行者的刀  阅读(1862)  评论(0)    收藏  举报