9
触发场景描述 write时 list数据泛型与指定的head class类型不一致时,且两个类字段顺序有差异时,会导致list中数据有字段丢失 触发Bug的代码 类及方法:com.alibaba.excel.write.executor.ExcelWriteAddExecutor#addJavaObjectToExcel
for (Map.Entry<Integer, Field> entry : sortedAllFiledMap.entrySet()) {
// here
_**cellIndex = entry.getKey();**_
Field field = entry.getValue();
String filedName = field.getName();
boolean uselessData = !beanMap.containsKey(filedName) || beanMapHandledSet.contains(filedName)
|| ignoreMap.containsKey(filedName);
if (uselessData) _{_
continue;
}
Object value = beanMap.get(filedName);
WriteHandlerUtils.beforeCellCreate(writeContext, row, null, cellIndex, relativeRowIndex, Boolean.FALSE);
// here
_**Cell cell = WorkBookUtil.createCell(row, cellIndex);**_
WriteHandlerUtils.afterCellCreate(writeContext, cell, null, relativeRowIndex, Boolean.FALSE);
CellData cellData = converterAndSet(currentWriteHolder, value == null ? null : value.getClass(), cell,
value, null, null, relativeRowIndex);
WriteHandlerUtils.afterCellDispose(writeContext, cellData, cell, null, relativeRowIndex, Boolean.FALSE);
}
提示的异常或者没有达到的效果 list中的一些字段被后面的空cell覆盖了