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

XSLX,如何读取,并解析excel中的内容,图片可以解析吗?
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>

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


回答:

看看这个库:https://github.com/exceljs/exceljs/blob/master/README_zh.md

以上是 XSLX,如何读取,并解析excel中的内容,图片可以解析吗? 的全部内容, 来源链接: utcz.com/p/934516.html

回到顶部