This commit is contained in:
zhoutianchi
2026-01-06 22:09:04 +08:00
parent 8af3aaa9b6
commit 3cf56a6b4c
2 changed files with 10 additions and 11 deletions

View File

@@ -35,7 +35,6 @@
"driver.js": "^0.9.8", "driver.js": "^0.9.8",
"echarts": "^5.4.1", "echarts": "^5.4.1",
"element-plus": "2.5.5", "element-plus": "2.5.5",
"file-saver": "^2.0.5",
"form-create-designer": "3.2.11-oem", "form-create-designer": "3.2.11-oem",
"highlight.js": "^11.7.0", "highlight.js": "^11.7.0",
"html-to-image": "^1.11.13", "html-to-image": "^1.11.13",

View File

@@ -1,6 +1,6 @@
/* eslint-disable */ /* eslint-disable */
import { saveAs } from 'file-saver' // import { saveAs } from 'file-saver'
import * as XLSX from 'xlsx' // import * as XLSX from 'xlsx'
// 现代浏览器已原生支持 Blob不需要 polyfill // 现代浏览器已原生支持 Blob不需要 polyfill
// 如果需要支持旧浏览器,可以取消下面的注释 // 如果需要支持旧浏览器,可以取消下面的注释
// import '/@/excel/Blob.js' // import '/@/excel/Blob.js'
@@ -62,21 +62,21 @@ function sheet_from_array_of_arrays(data, opts) {
if (range.e.c < C) range.e.c = C; if (range.e.c < C) range.e.c = C;
var cell = {v: data[R][C]}; var cell = {v: data[R][C]};
if (cell.v == null) continue; if (cell.v == null) continue;
var cell_ref = XLSX.utils.encode_cell({c: C, r: R}); // var cell_ref = XLSX.utils.encode_cell({c: C, r: R});
if (typeof cell.v === 'number') cell.t = 'n'; if (typeof cell.v === 'number') cell.t = 'n';
else if (typeof cell.v === 'boolean') cell.t = 'b'; else if (typeof cell.v === 'boolean') cell.t = 'b';
else if (cell.v instanceof Date) { else if (cell.v instanceof Date) {
cell.t = 'n'; // cell.t = 'n';
cell.z = XLSX.SSF._table[14]; // cell.z = XLSX.SSF._table[14];
cell.v = datenum(cell.v); // cell.v = datenum(cell.v);
} }
else cell.t = 's'; else cell.t = 's';
ws[cell_ref] = cell; ws[cell_ref] = cell;
} }
} }
if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range); // if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
return ws; return ws;
} }
@@ -114,9 +114,9 @@ export function export_table_to_excel(id) {
wb.SheetNames.push(ws_name); wb.SheetNames.push(ws_name);
wb.Sheets[ws_name] = ws; wb.Sheets[ws_name] = ws;
var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'}); // var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'});
saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), "test.xlsx") // saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), "test.xlsx")
} }
function formatJson(jsonData) { function formatJson(jsonData) {
@@ -137,7 +137,7 @@ export function export_json_to_excel(th, jsonData, defaultTitle) {
wb.SheetNames.push(ws_name); wb.SheetNames.push(ws_name);
wb.Sheets[ws_name] = ws; wb.Sheets[ws_name] = ws;
var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'}); // var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'});
var title = defaultTitle || '列表' var title = defaultTitle || '列表'
saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), title + ".xlsx") saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), title + ".xlsx")
} }