From fce685498d7746a0d40ae24635f5e801562dab84 Mon Sep 17 00:00:00 2001 From: yaojn Date: Mon, 4 Aug 2025 18:19:50 +0800 Subject: [PATCH] =?UTF-8?q?-=20[=E4=BF=AE=E5=A4=8D]=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=95=B0=E6=8D=AE=E6=8E=92=E9=99=A4=E7=A9=BA?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table-import-export-mixin.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/resources/plugins/TsSheet/form/component/formtableinputer/table-import-export-mixin.js b/src/resources/plugins/TsSheet/form/component/formtableinputer/table-import-export-mixin.js index f6c8614c..8130438e 100644 --- a/src/resources/plugins/TsSheet/form/component/formtableinputer/table-import-export-mixin.js +++ b/src/resources/plugins/TsSheet/form/component/formtableinputer/table-import-export-mixin.js @@ -141,7 +141,7 @@ export default { colIndexToKeyMap[index + 1] = key; } }); - for (let rowIndex = 2; rowIndex <= sheet.rowCount; rowIndex++) { + for (let rowIndex = 2; rowIndex <= this._getRowCount(sheet); rowIndex++) { // 从第二行开始读取数据,第一行是表头 const row = sheet.getRow(rowIndex); const rowData = { @@ -311,6 +311,28 @@ export default { }); return configList; }, + _getRowCount(sheet) { + // 获取非空行的数量 + let rowCount = 0; + // 遍历所有行 + for (let i = 1; i <= sheet.rowCount; i++) { + const row = sheet.getRow(i); + let isEmpty = true; + // 检查行是否有非空单元格 + if (row) { + for (const key in row) { + if (!this.$utils.isEmpty(row[key])) { + isEmpty = false; + break; + } + } + } + if (!isEmpty) { + rowCount++; + } + } + return rowCount; + }, _generateExcelHeaderConfig({ extraList = [] } = {}) { // 生成 Excel 导出所需的表头配置 let columnsList = []; -- Gitee