npm install --save xlsx file-saver
安装这个依赖后:
exportExcel() {
/* generate workbook object from table /
var wb = XLSX.utils.table_to_book(document.querySelector("#excel"));
/ 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;
},
导出的Excel数字太长变成科学计数法,请问怎么解决
试试把数字转化为字符串?
或者你除个一万?然后在表格那写个单位(万)
我也没试过。
我觉得转化为字符串可行
它本来就是字符串,就是在导出的时候被强制转换成数字了
<el-table-column label="订单号">
<template slot-scope="scope" width="160">
<div>{{scope.row.order_num}}*</div>
</template>
</el-table-column>