vue中使用插件实现excel导出
作者:互联网
1. 安装相关依赖
主要是两个依赖
npm install --save xlsx file-saver
2.组件里头引入
import FileSaver from 'file-saver'
import XLSX from 'xlsx'
3.调用
exportExcel () {
var wb = XLSX.utils.table_to_book(document.querySelector('#out-table'))
var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' })
FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), 'sheetjs.xlsx')
return wbout
},
标签:wbout,xlsx,插件,vue,XLSX,FileSaver,saver,excel,file 来源: https://blog.csdn.net/bigdargon/article/details/123184542