解决后续合并值不一致也误合并问题

This commit is contained in:
Simple 2023-12-08 12:04:06 +08:00
parent 3e85520c0f
commit e9bf70cb34

View File

@ -105,15 +105,22 @@ public class CellMergeStrategy extends AbstractMergeStrategy {
} }
} }
} else { } else {
RepeatCell firstCell = map.get(mergeFields.get(0)); if (!cellValue.equals(val)) {
if (repeatCell.getCurrent() != firstCell.getCurrent()) {
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));
} }
map.put(field, new RepeatCell(val, i)); map.put(field, new RepeatCell(val, i));
} else if (i == list.size() - 1) { } else {
if (i > repeatCell.getCurrent()) { RepeatCell firstCell = map.get(mergeFields.get(0));
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex, colNum, colNum)); 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));
}
} }
} }
} }