From 4cee79d80a60f2a7738feeb7c9053ed437308e63 Mon Sep 17 00:00:00 2001 From: xuliangzhan Date: Fri, 7 Jul 2023 08:24:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.ts | 16 ++++++++-------- package.json | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/index.ts b/index.ts index d791e9d..962ec25 100644 --- a/index.ts +++ b/index.ts @@ -126,8 +126,8 @@ function exportXLSX (params: InterceptorExportParams) { let beforeRowCount = 0 const colHead: any = {} columns.forEach((column) => { - const { id, property, renderWidth } = column - colHead[id] = original ? property : column.getTitle() + const { id, field, renderWidth, headerExportMethod } = column + colHead[id] = headerExportMethod ? headerExportMethod({ column, $table }) : (original ? field : column.getTitle()) sheetCols.push({ key: id, width: XEUtils.ceil(renderWidth / 8, 1) @@ -136,17 +136,17 @@ function exportXLSX (params: InterceptorExportParams) { // 处理表头 if (isHeader) { // 处理分组 - if (isColgroup && !original && colgroups) { + if (isColgroup && colgroups) { colgroups.forEach((cols, rIndex) => { const groupHead: any = {} columns.forEach((column) => { groupHead[column.id] = null }) cols.forEach((column) => { - const { _colSpan, _rowSpan } = column + const { _colSpan, _rowSpan, headerExportMethod } = column const validColumn = getValidColumn(column) const columnIndex = columns.indexOf(validColumn) - groupHead[validColumn.id] = original ? validColumn.property : column.getTitle() + groupHead[validColumn.id] = headerExportMethod ? headerExportMethod({ column, $table }) : (original ? validColumn.field : column.getTitle()) if (_colSpan > 1 || _rowSpan > 1) { sheetMerges.push({ s: { r: rIndex, c: columnIndex }, @@ -162,7 +162,7 @@ function exportXLSX (params: InterceptorExportParams) { beforeRowCount += colList.length } // 处理合并 - if (isMerge && !original) { + if (isMerge) { mergeCells.forEach(mergeItem => { const { row: mergeRowIndex, rowspan: mergeRowspan, col: mergeColIndex, colspan: mergeColspan } = mergeItem sheetMerges.push({ @@ -185,7 +185,7 @@ function exportXLSX (params: InterceptorExportParams) { const footers = getFooterData(options, footerData) const mergeFooterItems = $table.getMergeFooterItems() // 处理合并 - if (isMerge && !original) { + if (isMerge) { mergeFooterItems.forEach(mergeItem => { const { row: mergeRowIndex, rowspan: mergeRowspan, col: mergeColIndex, colspan: mergeColspan } = mergeItem sheetMerges.push({ @@ -367,7 +367,7 @@ function importXLSX (params: InterceptorImportParams) { fileReader.onload = (evnt) => { const tableFields: string[] = [] columns.forEach((column) => { - const field = column.property + const field = column.field if (field) { tableFields.push(field) } diff --git a/package.json b/package.json index 846488a..861aecf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vxe-table-plugin-export-xlsx", - "version": "2.2.2", + "version": "2.2.3", "description": "基于 vxe-table 的表格插件,支持导出 xlsx 格式", "scripts": { "lib": "gulp build" @@ -49,8 +49,8 @@ "prettier": "^2.1.2", "typescript": "^4.6.4", "vue": "^2.6.14", - "vxe-table": "^3.6.13", - "xe-utils": "^3.5.7" + "vxe-table": "^3.6.17", + "xe-utils": "^3.5.11" }, "peerDependencies": { "vxe-table": "^2.10.0 || ^3.2.0"