From 2a34c3ebb283dff31f53533457e02c2339ba4952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E9=93=83=E8=96=AF=E5=A4=B4?= <5601833+xlsea@user.noreply.gitee.com> Date: Fri, 18 Apr 2025 05:30:12 +0000 Subject: [PATCH] =?UTF-8?q?!672=20fix:=20=E4=BF=AE=E5=A4=8D=20excel=20?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=8D=95=E5=85=83=E6=A0=BC=E5=9C=A8=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=9C=A8=E6=9C=80=E5=90=8E=E4=B8=80=E8=A1=8C=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=90=88=E5=B9=B6=E6=97=B6=EF=BC=8C=E4=B9=8B=E5=89=8D?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E5=90=88=E5=B9=B6=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20*=20fix:=20=E4=BF=AE=E5=A4=8D=20excel=20?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=8D=95=E5=85=83=E6=A0=BC=E5=9C=A8=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=9C=A8=E6=9C=80=E5=90=8E=E4=B8=80=E8=A1=8C=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=90=88=E5=B9=B6=E6=97=B6=EF=BC=8C=E4=B9=8B=E5=89=8D?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E5=90=88=E5=B9=B6=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/dromara/common/excel/core/CellMergeStrategy.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/CellMergeStrategy.java b/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/CellMergeStrategy.java index 7c7721c60..1c7d97fc4 100644 --- a/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/CellMergeStrategy.java +++ b/ruoyi-common/ruoyi-common-excel/src/main/java/org/dromara/common/excel/core/CellMergeStrategy.java @@ -112,7 +112,13 @@ public class CellMergeStrategy extends AbstractMergeStrategy implements Workbook } map.put(field, new RepeatCell(val, i)); } else if (i == list.size() - 1) { - if (i > repeatCell.getCurrent() && isMerge(list, i, field)) { + if (!isMerge(list, i, field)) { + // 如果最后一行不能合并,检查之前的数据是否需要合并 + if (i - repeatCell.getCurrent() > 1) { + cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex - 1, colNum, colNum)); + } + } else if (i > repeatCell.getCurrent()) { + // 如果最后一行可以合并,则直接合并到最后 cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex, colNum, colNum)); } } else if (!isMerge(list, i, field)) {