!672 fix: 修复 excel 合并单元格在导出在最后一行无法合并时,之前的数据合并失效问题

* fix: 修复 excel 合并单元格在导出在最后一行无法合并时,之前的数据合并失效问题
This commit is contained in:
马铃薯头 2025-04-18 05:30:12 +00:00 committed by 疯狂的狮子Li
parent 3b46f8c8cf
commit 2a34c3ebb2

View File

@ -112,7 +112,13 @@ public class CellMergeStrategy extends AbstractMergeStrategy implements Workbook
} }
map.put(field, new RepeatCell(val, i)); map.put(field, new RepeatCell(val, i));
} else if (i == list.size() - 1) { } 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)); cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex, colNum, colNum));
} }
} else if (!isMerge(list, i, field)) { } else if (!isMerge(list, i, field)) {