首先在Export2Excel.js文件中引入:import JSZip from 'jszip'
将Export2Excel.js文件最下方的代码
saveAs(new Blob([s2ab(wbout)], {
type: "application/octet-stream"
}), `
改成如下代码即可
const zip = new JSZip()
const zip_name = filename || 'file'
const data = new Blob([s2ab(wbout)], {
type: "application/octet-stream"
})
zip.file(`${filename}.${bookType}`, data, { binary: true }) // 逐个添加文件
//可添加多个excel:zip.file(`${filename2}.${bookType}`, data, { binary: true })
zip.generateAsync({
type: "blob"
}).then((blob) => {
saveAs(blob, `${zip_name}.zip`)
}, (err) => {
alert('导出失败')
})