ArrayBuffer主要将二进制码转译为二进制数组
const uInt8Array = new Uint8Array(content); //先将返回的二进制数组转化为js的二进制数组
const blob=new Blob([uInt8Array],{type:"application/vnd.ms-excel"});//然后创建blob对象,文件类型设置为excel的类型
const blobURL = window.URL.createObjectURL(blob);//然后创建一个可访问的URL
const tempLink = document.createElement('a');//创建a标签去下载
tempLink.style.display = 'none';
tempLink.href = blobURL;
tempLink.setAttribute('download', fileName+".xlsx");
if (typeof tempLink.download === 'undefined') {
tempLink.setAttribute('target', '_blank');
}
document.body.appendChild(tempLink);
tempLink.click();
document.body.removeChild(tempLink);
window.URL.revokeObjectURL(blobURL);
详细查看(ArrayBuffer)http://www.freesion.com/article/442667984/
这篇博客探讨了如何利用ArrayBuffer处理Excel文件的二进制流,将其转换为二进制数组,以便进行进一步操作。内容引用了相关的在线资源链接,提供详细解析。
5343

被折叠的 条评论
为什么被折叠?



