import * as XLSX from "xlsx";
export function readExcel(file) {
  return new Promise((resolve, reject) => {
    try {
      //获取上传对象
      const fileReader = new FileReader();
      fileReader.onload = (event) => {
        console.log(event);
        const fileData = event.target.result;
        //读取excel文件
        const workboot = XLSX.read(fileData, {
          type: "binary",
        });
        let sheel0 = workboot.SheetNames[0];
        let blockArr = XLSX.utils.sheet_to_json(workboot.Sheets[sheel0]);
        resolve(blockArr);
      };
      fileReader.readAsBinaryString(file);
    } catch (e) {
      reject(e);
      // set_loading(false);
    }
  });
};
