使用方式可参考blog.csdn.net/yuzheng7002…
我这里主要展示使用过程中遇到的一个问题,希望可以帮到你
问题场景
在使用
const importData = XLSX.read(content, {type:'binary'});
的时候报错Cannot find file [Content_Types].xml in zip
方案一:
网上有说XLSX@0.16.0版本太高,换成@0.14.2版本即可,我没有尝试这种方案,但它或许对你有用,因此我也把它列了出来
方案二:
由于我是按照readAsText(file)读取的文件,但XLSX.read(content, {type:'binary'});应该是要求读取binaryString类型的文件,因此报了该错 修改为
const reader = new FileReader();
reader.readAsBinaryString(file.file);
reader.onload = (e)=>{
const content = e.target.result;
const importData = XLSX.read(content, {type:'binary'});
console.log(importData);
}
就成功了