cnpm install --save xlsx file-saver
import FileSaver from "file-saver";
import XLSX from "xlsx";
exportexcel() {//设置当前日期let time = new Date();let year = FullYear();let month = Month() + 1;let day = Date();let name = year + "" + month + "" + day;//console.log(name)//选择要导出的表格var wb = XLSX.utils.table_to_book(document.querySelector(".table"));//console.log(wb)/* get binary string as output */var wbout = XLSX.write(wb, {bookType: "xlsx",bookSST: true,type: "array"});//console.log(wbout)try {// name+'.xlsx'表示导出的excel表格名字FileSaver.saveAs(new Blob([wbout], { type: "application/octet-stream" }),name + ".xlsx");} catch (e) {if (typeof console !== "undefined") console.log(e, wbout);}return wbout;},
本文发布于:2024-01-29 15:34:27,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170651367116281.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |