Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rockRust opened this issue Apr 15, 2021 · 4 comments
Assignees
Labels
bug Something isn't working development completed Development completed, waiting for release pending verification This problem needs to be confirmed question Further information is requested

Comments

@rockRust
Copy link
Contributor

触发场景描述
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覆盖了

@rockRust rockRust added the bug Something isn't working label Apr 15, 2021
@rockRust
Copy link
Contributor Author

已解决,见pr#1871

@zhuangjiaju
Copy link
Collaborator

非常感谢您的pr.

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

@zhuangjiaju zhuangjiaju added the question Further information is requested label Apr 19, 2021
@rockRust
Copy link
Contributor Author

非常感谢您的pr.

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

@zhuangjiaju zhuangjiaju added pending verification This problem needs to be confirmed development completed Development completed, waiting for release labels Sep 14, 2021
@zhuangjiaju
Copy link
Collaborator

zhuangjiaju commented Sep 17, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working development completed Development completed, waiting for release pending verification This problem needs to be confirmed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants