From 817793be6e72c2869d19c28f905367656004dc12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E5=84=80=E5=BC=8F?= <854085467@qq.com> Date: Sat, 16 Apr 2022 14:03:15 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=20xlsx=20=E4=BE=9D?= =?UTF-8?q?=E8=B5=96,=20=E9=87=8D=E6=9E=84=20table=20=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/src/component/table/index.vue | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/package/component/src/component/table/index.vue b/package/component/src/component/table/index.vue index 1bcda873..7e47756d 100644 --- a/package/component/src/component/table/index.vue +++ b/package/component/src/component/table/index.vue @@ -121,9 +121,9 @@ const print = function () { const exportData = () => { const head = []; const body = []; - tableColumns.value.forEach(item => { + tableColumns.value.forEach((item) => { head.push(item.title); - }) + }); tableDataSource.value.forEach((item) => { let obj = []; tableColumns.value.forEach((tableColumn) => { @@ -137,19 +137,19 @@ const exportData = () => { }); body.push(obj); }); - exportToExcel(head, body) + exportToExcel(head, body); return; }; -function exportToExcel(headerList, bodyList){ +function exportToExcel(headerList, bodyList) { let excelList = []; excelList.push(headerList.join("\t,")); excelList.push("\n"); - bodyList.forEach(item=>{ - excelList.push(item.join("\t,")); - excelList.push("\n"); - }) - var merged = excelList .join(""); + bodyList.forEach((item) => { + excelList.push(item.join("\t,")); + excelList.push("\n"); + }); + var merged = excelList.join(""); let link = document.createElement("a"); link.href = "data:text/xls;charset=utf-8,\ufeff" + encodeURIComponent(merged); link.download = `table.xls`;