码迷,mamicode.com
首页 > 其他好文 > 详细

elementUI+vue-cli el-table=》excel

时间:2018-08-01 11:47:29      阅读:197      评论:0      收藏:0      [点我收藏+]

标签: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‘
4.
<el-button class="fr el-button--success" @click="exportExcel">导出excel</el-button>
5.
<el-table id="rebateSetTable"
6.
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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!