vue3 excel下载 xlsx插件

1.安装插件:

npm install --save xlsx file-saver

 

2.页面中引入

  1. // 引入file插件
  2.  
    import FileSaver from "file-saver";
  3.  
    // 引入xlsx插件
  4.  
    import * as XLSX from "xlsx";
     
     
     
    3.事件

const export = () => {
//导出当前表格
var wb = XLSX.utils.table_to_book(document.querySelector("#tableId")); //表格id
var wbout = XLSX.write(wb, {
bookType: "xlsx",
bookSST: true,
type: "array",
});
try {
FileSaver.saveAs(
new Blob([wbout], { type: "application/octet-stream" }),
"order.xlsx"
); //文件名
} catch (e) {
if (typeof console !== "undefined") console.log(e, wbout);
}
return wbout;
},

posted @   elliot1004  阅读(1455)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Blazor Hybrid适配到HarmonyOS系统
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 解决跨域问题的这6种方案,真香!
· 分享4款.NET开源、免费、实用的商城系统
· 一套基于 Material Design 规范实现的 Blazor 和 Razor 通用组件库
点击右上角即可分享
微信分享提示