[alibaba/easyexcel]写操作-list中classType与指定的head的类型不一致,导致部分字段被覆盖为空cell

2024-05-11 406 views
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覆盖了

回答

7

已解决,见pr#1871

4

非常感谢您的pr.

  1. 导包排序有问题 不允许出现*
  2. 我没有看懂具体问题是啥
  3. 153行 Cell cell = WorkBookUtil.createCell(row, cellIndex++) 什么意思 没懂
0

非常感谢您的pr.

  1. 导包排序有问题 不允许出现* 已解决
  2. 我没有看懂具体问题是啥 已私聊
  3. 153行 Cell cell = WorkBookUtil.createCell(row, cellIndex++) 什么意思 没懂 已私聊
3

已经在3.0.0-beta1 版本修复,beta版本会在一个月内升级成正式版。