标签:work ons books ica alt binary gre port https
1.npm install --save xlsx file-saver
2.
https://github.com/SheetJS/js-xlsx
https://github.com/eligrey/FileSaver.js
3.组件头
import FileSaver from ‘file-saver‘
import XLSX from ‘xlsx‘
<el-button class="fr el-button--success" @click="exportExcel">导出excel</el-button>
<el-table id="rebateSetTable"
exportExcel () {
/* generate workbook object from table */
let wb = XLSX.utils.table_to_book(document.querySelector(‘#rebateSetTable‘));
/* get binary string as output */
let wbout = XLSX.write(wb, { bookType: ‘xlsx‘, bookSST: true, type: ‘array‘ });
try {
FileSaver.saveAs(new Blob([wbout], { type: ‘application/octet-stream‘ }), ‘组态继承.xlsx‘);
} catch (e)
{
if (typeof console !== ‘undefined‘)
console.log(e, wbout)
}
return wbout
},
elementUI+vue-cli el-table=》excel
标签:work ons books ica alt binary gre port https
原文地址:https://www.cnblogs.com/xianyk/p/9399436.html