mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
fix 导出Excel时设置合并列,指定合并列的第一行数据为null、空字符时导致后续列无法正常合并
This commit is contained in:
parent
c01ed34602
commit
b345702705
@ -73,12 +73,14 @@ public class CellMergeHandler {
|
||||
Object val = ReflectUtils.invokeGetter(rowObj, field.getName());
|
||||
|
||||
int colNum = mergeFieldsIndex.get(j);
|
||||
if (!map.containsKey(field)) {
|
||||
Object cellValue = map.containsKey(field) ? map.get(field).value() : null;
|
||||
|
||||
if (!map.containsKey(field) || (isEmpty(cellValue) && val != null)) {
|
||||
map.put(field, new RepeatCell(val, i));
|
||||
} else {
|
||||
RepeatCell repeatCell = map.get(field);
|
||||
Object cellValue = repeatCell.value();
|
||||
if (cellValue == null || "".equals(cellValue)) {
|
||||
cellValue = repeatCell.value();
|
||||
if (isEmpty(cellValue)) {
|
||||
// 空值跳过不合并
|
||||
continue;
|
||||
}
|
||||
@ -110,6 +112,10 @@ public class CellMergeHandler {
|
||||
return cellList;
|
||||
}
|
||||
|
||||
private boolean isEmpty(Object value) {
|
||||
return value == null || "".equals(value);
|
||||
}
|
||||
|
||||
private boolean isMerge(List<?> list, int i, Field field) {
|
||||
boolean isMerge = true;
|
||||
CellMerge cm = field.getAnnotation(CellMerge.class);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user