import * as XLSX from "xlsx"; exportExcel() { var wb = XLSX.utils.table_to_book(document.querySelector('#data-table2'), { raw: true}); var wbout = XLSX.write(wb, { bookType: 'xls', book: true, type: 'array', }) try { FileSaver.saveAs( new Blob([wbout], { type: 'appliction/octet-stream' }), '检查记录明细.xls' ) } catch (e) { if (typeof console != 'undefined') console.log(e, wbout); } return wbout }, exportExcelAsHTML() { var html = "<html><head><meta charset='utf-8' /></head><body>" + $("#data-table").html() + "</body></html>"; var now = new Date(); var date = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate() + ' ' + now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds(); var fileName = $(".title").html(); var exportFileName = fileName + date + ' ' + ".xls";//自定义导出excel表名称 var blob = new Blob([html], { type: "application/vnd.ms-excel" }); saveAs(blob, exportFileName); }
标签:wbout,XLSX,vue,Excel,导出,html,var,now,type From: https://www.cnblogs.com/nanfei/p/17277186.html