Open zhaobinglong opened 3 years ago
link:https://github.com/SheetJS/js-xlsx
import FileSaver from 'file-saver'
import XLSX from 'xlsx'
exportExcel() {
/* generate workbook object from table */
var wb = XLSX.utils.table_to_book(document.querySelector(".my-table"))
/* get binary string as output */
var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' })
try {
FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), 'sheetjs.xlsx')
} catch (e) {
if (typeof console !== 'undefined') {
console.log(e, wbout)
}
}
return wbout
},
exportExcel() {
/* 添加 { raw: true } */
var wb = XLSX.utils.table_to_book(document.querySelector("#my-table"), { raw: true })
},
配置npm私有仓库地址