diff --git a/src/utlis/Export2Excel.js b/src/utlis/Export2Excel.js index d657c61..5992269 100644 --- a/src/utlis/Export2Excel.js +++ b/src/utlis/Export2Excel.js @@ -308,7 +308,6 @@ export function exportToExceLlineBreak(idSelector, fileName, isNew, list, titleN let va = cell.v; // 确保va是字符串类型再进行处理 if (typeof va === 'string') { - console.log(va) // 替换回车符为换行符进行计算 - 统一使用 \n 计算宽度 va = va.replace(/\r\n/g, '\n'); var card1 = va.match(/[\u4e00-\u9fa5]/g); //匹配中文 @@ -364,27 +363,27 @@ export function exportToExceLlineBreak(idSelector, fileName, isNew, list, titleN } ws['!rows'] = rowHeights; - // // 检查是否可以使用xlsx-style,否则使用标准xlsx - // let wbout; - // try { - // // 尝试使用xlsx-style(如果已安装) - // if (typeof XLSXStyle !== 'undefined' && XLSXStyle && XLSXStyle.write) { - // wbout = XLSXStyle.write(wb, { bookType: 'xlsx', bookSST: false, type: 'binary', cellStyles: true }); - // } else { - // // 如果xlsx-style不可用,使用标准xlsx并设置参数以支持样式 - // wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: false, type: 'binary', cellStyles: true }); - // } - // } catch (e) { - // // 如果xlsx-style失败,回退到标准xlsx - // wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: false, type: 'binary', cellStyles: true }); - // } + // 检查是否可以使用xlsx-style,否则使用标准xlsx + let wbout; + try { + // 尝试使用xlsx-style(如果已安装) + if (typeof XLSXStyle !== 'undefined' && XLSXStyle && XLSXStyle.write) { + wbout = XLSXStyle.write(wb, { bookType: 'xlsx', bookSST: false, type: 'binary', cellStyles: true }); + } else { + // 如果xlsx-style不可用,使用标准xlsx并设置参数以支持样式 + wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: false, type: 'binary', cellStyles: true }); + } + } catch (e) { + // 如果xlsx-style失败,回退到标准xlsx + wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: false, type: 'binary', cellStyles: true }); + } - // try { - // saveAs(new Blob([s2ab(wbout)], { type: '' }), `${fileName}.xlsx`) - // } catch (e) { - // if (typeof console !== 'undefined') { - // console.log(e, wbout) - // } - // } - // return wbout + try { + saveAs(new Blob([s2ab(wbout)], { type: '' }), `${fileName}.xlsx`) + } catch (e) { + if (typeof console !== 'undefined') { + console.log(e, wbout) + } + } + return wbout } \ No newline at end of file diff --git a/src/views/customerReport/personnelPositive.vue b/src/views/customerReport/personnelPositive.vue index aa81f2d..ac15d19 100644 --- a/src/views/customerReport/personnelPositive.vue +++ b/src/views/customerReport/personnelPositive.vue @@ -28,8 +28,7 @@