vue如何导出excel?
项目是用cdn方式引入js的,没有用到npm.
<script type="text/javascript" src="/static/vue/js/vue.js"></script><script type="text/javascript" src="/static/vue/js/index.js"></script>
<script type="text/javascript" src="/static/vue/js/axios.min.js"></script>
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js"></script>
let xlsxParam = { raw: true };let wb = XLSX.utils.table_to_book(
document.querySelector(id),
xlsxParam
);
let wbout = XLSX.write(wb, {bookType: "xlsx", bookSST: true, type: "array",});
try {
saveAs(new Blob([wbout], { type: "application/octet-stream" }), "文件.xlsx");
} catch (e) {
console.log(e, wbout);
}
return wbout;
最近https://unpkg.com/ 访问不了了, 得如何实现导出excel
回答:
可以用vue-json-excel
:
<script src="https://cdn.jsdelivr.net/npm/vue-json-excel@0.3.0/dist/vue-json-excel.umd.min.js"></script>
https://www.npmjs.com/package/vue-json-excel
https://www.jsdelivr.com/package/npm/vue-json-excel
另外unpkg
可以访问:
以上是 vue如何导出excel? 的全部内容, 来源链接: utcz.com/p/934853.html