From f83f6708bb650f60e15434eedae9f8f100e7ef0a Mon Sep 17 00:00:00 2001 From: xlsea Date: Fri, 18 Apr 2025 12:00:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20excel=20=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E5=8D=95=E5=85=83=E6=A0=BC=E5=9C=A8=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=9C=A8=E6=9C=80=E5=90=8E=E4=B8=80=E8=A1=8C=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=97=B6=EF=BC=8C=E4=B9=8B=E5=89=8D=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=90=88=E5=B9=B6=E5=A4=B1=E6=95=88=E9=97=AE?= =?UTF-8?q?=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)) {