From b345702705c175ed36c4eaaa8a8f547da4f48b86 Mon Sep 17 00:00:00 2001 From: zhengyulun Date: Tue, 26 Aug 2025 15:41:35 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix=20=E5=AF=BC=E5=87=BAExcel=E6=97=B6?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=90=88=E5=B9=B6=E5=88=97=EF=BC=8C=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E5=90=88=E5=B9=B6=E5=88=97=E7=9A=84=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E8=A1=8C=E6=95=B0=E6=8D=AE=E4=B8=BAnull=E3=80=81=E7=A9=BA?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E6=97=B6=E5=AF=BC=E8=87=B4=E5=90=8E=E7=BB=AD?= =?UTF-8?q?=E5=88=97=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/common/excel/core/CellMergeHandler.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/CellMergeHandler.java b/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/CellMergeHandler.java index dd37b6795..f811cdd7e 100644 --- a/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/CellMergeHandler.java +++ b/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/CellMergeHandler.java @@ -73,12 +73,14 @@ public class CellMergeHandler { Object val = ReflectUtils.invokeGetter(rowObj, field.getName()); int colNum = mergeFieldsIndex.get(j); - if (!map.containsKey(field)) { + Object cellValue = map.containsKey(field) ? map.get(field).value() : null; + + if (!map.containsKey(field) || (isEmpty(cellValue) && val != null)) { map.put(field, new RepeatCell(val, i)); } else { RepeatCell repeatCell = map.get(field); - Object cellValue = repeatCell.value(); - if (cellValue == null || "".equals(cellValue)) { + cellValue = repeatCell.value(); + if (isEmpty(cellValue)) { // 空值跳过不合并 continue; } @@ -110,6 +112,10 @@ public class CellMergeHandler { return cellList; } + private boolean isEmpty(Object value) { + return value == null || "".equals(value); + } + private boolean isMerge(List list, int i, Field field) { boolean isMerge = true; CellMerge cm = field.getAnnotation(CellMerge.class); -- Gitee From 701a137a688b8b05c96537ab035b5ab52d9edc89 Mon Sep 17 00:00:00 2001 From: zhengyulun Date: Tue, 26 Aug 2025 15:56:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=20=E5=AF=BC=E5=87=BAExcel=E6=97=B6?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=90=88=E5=B9=B6=E5=88=97=EF=BC=8C=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E5=90=88=E5=B9=B6=E5=88=97=E7=9A=84=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E8=A1=8C=E6=95=B0=E6=8D=AE=E4=B8=BAnull=E3=80=81=E7=A9=BA?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E6=97=B6=E5=AF=BC=E8=87=B4=E5=90=8E=E7=BB=AD?= =?UTF-8?q?=E5=88=97=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/dromara/common/excel/core/CellMergeHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/CellMergeHandler.java b/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/CellMergeHandler.java index f811cdd7e..90a0b9925 100644 --- a/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/CellMergeHandler.java +++ b/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/CellMergeHandler.java @@ -79,7 +79,6 @@ public class CellMergeHandler { map.put(field, new RepeatCell(val, i)); } else { RepeatCell repeatCell = map.get(field); - cellValue = repeatCell.value(); if (isEmpty(cellValue)) { // 空值跳过不合并 continue; -- Gitee