核心提示:vue关于excel导出的操作讲解//npm install --save xlsx file-saver//需要调用的组件import FileSaver from file-saverimport...
vue关于excel导出的操作讲解
//npm install --save xlsx file-saver //需要调用的组件 import FileSaver from 'file-saver' import XLSX from 'xlsx' //导出方法,sheetjs.xlsx为文件名可更改,out-table为导出table id exportExcel () { /* generate workbook object from table */ var wb = XLSX.utils.table_to_book(document.querySelector('#out-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 },