Pre Merge pull request !455 from simple/excelCellMerge

This commit is contained in:
simple 2023-11-29 07:35:38 +00:00 committed by Gitee
commit d6a14b6cfd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -93,6 +93,7 @@ public class CellMergeStrategy extends AbstractMergeStrategy {
// 空值跳过不合并 // 空值跳过不合并
continue; continue;
} }
if (j == 0) {
if (!cellValue.equals(val)) { if (!cellValue.equals(val)) {
if (i - repeatCell.getCurrent() > 1) { if (i - repeatCell.getCurrent() > 1) {
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex - 1, colNum, colNum)); cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex - 1, colNum, colNum));
@ -103,6 +104,19 @@ public class CellMergeStrategy extends AbstractMergeStrategy {
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex, colNum, colNum)); cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex, colNum, colNum));
} }
} }
} else {
RepeatCell firstCell = map.get(mergeFields.get(0));
if (repeatCell.getCurrent() != firstCell.getCurrent()) {
if (i - repeatCell.getCurrent() > 1) {
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex - 1, colNum, colNum));
}
map.put(field, new RepeatCell(val, i));
} else if (i == list.size() - 1) {
if (i > repeatCell.getCurrent()) {
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex, colNum, colNum));
}
}
}
} }
} }
} }