XSLX,如何读取,并解析excel中的内容,图片可以解析吗?

image.png
XSLX,如何读取,并解析excel中的内容?打印出并不包含图片内容?

<template>
  <el-upload
    ref="xlsx-upload"
    class="xlsx-upload"
    action=""
    :auto-upload="false"
    :file-list="fileList"
    :on-change="handleChange"
    :multiple="false"
    :show-file-list="false"
  >
    <el-button type="primary" size="small" plain>点击上传</el-button>
  </el-upload>
</template>
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
import XLSX from "xlsx";
@Component({})
export default class BulkImport extends Vue {
  fileList: any = [];
  file: any = "";
  /* --- --- 方法区域  --- --- */
  handleChange(file: any, fileList: any) {
    console.log("更新------", file, "bbbbbbbbb", fileList);
    this.fileList = [fileList[fileList.length - 1]]; //只能上传一个`Excel`,重复上传会覆盖之前的
    this.file = file.raw;
    const reader = new FileReader();
    reader.readAsArrayBuffer(this.file);
    reader.onload = () => {
      const buffer: any = reader.result;
      const bytes = new Uint8Array(buffer);
      const length = bytes.byteLength;
      let binary = "";
      for (let i = 0; i < length; i++) {
        binary += String.fromCharCode(bytes[i]);
      }
      const wb = XLSX.read(binary, { type: "binary", cellDates: true }); //cellDates,设置为true,将天数的时间戳转为时间格式
      const outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
      console.log("outdata", outdata);
    };
  }
}
</script>

image.png

阅读 4.4k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏