From 0530a9d307086ea2ba9c7e45c18b1b46f08db454 Mon Sep 17 00:00:00 2001 From: Lau Date: Fri, 13 Mar 2026 14:20:35 +0000 Subject: [PATCH 1/2] =?UTF-8?q?update=20=E4=BF=AE=E6=94=B9vben5=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E4=BB=93=E5=BA=93=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 96dc4ca5e..364615dbb 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ > 系统演示: [传送门](https://plus-doc.dromara.org/#/common/demo_system) > 官方前端项目地址: [gitee](https://gitee.com/JavaLionLi/plus-ui) - [github](https://github.com/JavaLionLi/plus-ui) - [gitcode](https://gitcode.com/dromara/plus-ui)
-> 成员前端项目地址: 基于vben5 [ruoyi-plus-vben5](https://gitee.com/dapppp/ruoyi-plus-vben5)
+> 成员前端项目地址: 基于vben5 [ruoyi-plus-vben5](https://github.com/imdap/ruoyi-plus-vben5)
> 成员前端项目地址: 基于soybean [ruoyi-plus-soybean](https://gitee.com/xlsea/ruoyi-plus-soybean)
> 成员项目地址: 删除多租户与工作流 [RuoYi-Vue-Plus-Single](https://gitee.com/ColorDreams/RuoYi-Vue-Plus-Single)
From 0dd3b8dc5161cb96874c3fea1f06c13e8d7027fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Mon, 16 Mar 2026 18:00:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=20excel=E7=BB=93?= =?UTF-8?q?=E5=B0=BE=E5=87=BA=E7=8E=B0=E7=A9=BA=E7=99=BD=E6=A0=BC=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=90=88=E5=B9=B6=E7=AD=96=E7=95=A5=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/excel/core/CellMergeHandler.java | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 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 6a1a3a72d..624117585 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 @@ -64,8 +64,10 @@ public class CellMergeHandler { // 当前行数据字段值 Object currentRowObjFieldVal = ReflectUtils.invokeGetter(currentRowObj, field.getName()); - // 空值跳过不处理 - if (currentRowObjFieldVal == null || "".equals(currentRowObjFieldVal)) { + // 空值视为合并中断,需要先收口上一段合并区间 + if (isBlankCell(currentRowObjFieldVal)) { + appendMergeResult(result, rowRepeatCellMap.get(field), i - 1, colNum); + rowRepeatCellMap.remove(field); continue; } @@ -78,7 +80,6 @@ public class CellMergeHandler { // 获取 单元格合并Map 中字段值 RepeatCell repeatCell = rowRepeatCellMap.get(field); Object cellValue = repeatCell.value(); - int current = repeatCell.current(); // 检查是否满足合并条件 // currentRowObj 当前行数据 @@ -86,33 +87,14 @@ public class CellMergeHandler { // cellMerge 当前行字段合并注解 boolean merge = isMerge(currentRowObj, rows.get(i - 1), cellMerge); - // 是否添加到结果集 - boolean isAddResult = false; - // 最新行 - int lastRow = i + rowIndex - 1; - // 如果当前行字段值和缓存中的字段值不相等,或不满足合并条件,则替换 if (!currentRowObjFieldVal.equals(cellValue) || !merge) { + appendMergeResult(result, repeatCell, i - 1, colNum); rowRepeatCellMap.put(field, RepeatCell.of(currentRowObjFieldVal, i)); - isAddResult = true; - } - - // 如果最后一行不能合并,检查之前的数据是否需要合并;如果最后一行可以合并,则直接合并到最后 - if (i == rows.size() - 1) { - isAddResult = true; - if (i > current) { - lastRow = i + rowIndex; - } - } - - if (isAddResult && i > current) { - //如果是同一行,则跳过合并 - if (current + rowIndex == lastRow) { - continue; - } - result.add(new CellRangeAddress(current + rowIndex, lastRow, colNum, colNum)); } } + appendMergeResult(result, rowRepeatCellMap.get(field), rows.size() - 1, colNum); + rowRepeatCellMap.remove(field); } return result; } @@ -167,6 +149,17 @@ public class CellMergeHandler { return true; } + private boolean isBlankCell(Object value) { + return value == null || StrUtil.isBlankIfStr(value); + } + + private void appendMergeResult(List result, RepeatCell repeatCell, int endIndex, int colNum) { + if (repeatCell == null || endIndex <= repeatCell.current()) { + return; + } + result.add(new CellRangeAddress(repeatCell.current() + rowIndex, endIndex + rowIndex, colNum, colNum)); + } + /** * 单元格合并 */