Browse Source

修复导出

dev
qb 1 month ago
parent
commit
9cd6d1c0d3
  1. 8
      src/utils/exportData.js

8
src/utils/exportData.js

@ -2,6 +2,8 @@ import XLSX from 'xlsx-js-style';
import { getObjType, isNumber } from '@/utils/util';
export function exportExcel(columnList = [], listData = [], name = 'excel') {
console.log('listData :>> ', listData);
// 创建工作簿
const wb = XLSX.utils.book_new();
@ -25,7 +27,7 @@ export function exportExcel(columnList = [], listData = [], name = 'excel') {
if (blackArr.includes(val.label) || val.head) continue;
if (val.isColumnMerge && isNumber(item.mergeColumnIndex) && item.mergeColumnIndex > 1) {
marginList.push({ s: { r: j, c: i }, e: { r: j + item.mergeColumnIndex, c: i } });
marginList.push({ s: { r: j + 1, c: i }, e: { r: j + item.mergeColumnIndex, c: i } });
}
if (j === 0) headers.push(val.label);
@ -45,7 +47,7 @@ export function exportExcel(columnList = [], listData = [], name = 'excel') {
// 创建工作表
const ws = XLSX.utils.aoa_to_sheet(ws_data);
console.log('ws :>> ', ws);
// console.log('ws :>> ', ws);
// 1.所有表头的宽度
const headsWidth = headers.map(value => {
@ -69,8 +71,6 @@ export function exportExcel(columnList = [], listData = [], name = 'excel') {
valueWidth = parseFloat(value.toString().length * 1.1) + 4;
}
console.log('valueWidth :>> ', valueWidth);
console.log('value :>> ', value);
// console.log("每行数据中值的宽度:", valueWidth);
// 对比出表头和表体值的最大数

Loading…
Cancel
Save