feat: 增加导出功能

This commit is contained in:
2025-12-16 21:28:17 +08:00
parent 941bd6fe57
commit 69ddc7c007
8 changed files with 275 additions and 32 deletions

View File

@ -11,6 +11,12 @@ export function easyExport(data, fileName = '导出文件') {
const wb = XLSX.utils.book_new();
// 二维数组例子:[ ['姓名', '年龄', '城市'], ['张三', 25, '北京'], ['李四', 30, '上海'] ];
const ws = XLSX.utils.aoa_to_sheet(data); // aoa_to_sheet 方法将二维数组转换为工作表
// 宽度调整
ws['!cols'] = Array(data?.[0]?.length || 0).fill({ wpx: 80 });
XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
XLSX.writeFile(wb, fileName + '.xlsx');
}