Browse Source

修复`includeColumnIndexes`不包含第列 会无法导出数据的bug #1346

developing
Jiaju Zhuang 4 years ago
parent
commit
9d60fa6745
  1. 9
      src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java
  2. 1
      src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java
  3. 1
      update.md

9
src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java

@ -73,7 +73,7 @@ public class ExcelHeadProperty {
int headIndex = 0;
for (int i = 0; i < head.size(); i++) {
if (holder instanceof AbstractWriteHolder) {
if (((AbstractWriteHolder)holder).ignore(null, i)) {
if (((AbstractWriteHolder) holder).ignore(null, i)) {
continue;
}
}
@ -130,9 +130,8 @@ public class ExcelHeadProperty {
index++;
}
}
if (!initOneColumnProperty(holder, index, field, Boolean.FALSE)) {
index++;
}
initOneColumnProperty(holder, index, field, Boolean.FALSE);
index++;
}
for (Map.Entry<Integer, Field> entry : customFiledMap.entrySet()) {
initOneColumnProperty(holder, entry.getKey(), entry.getValue(), Boolean.TRUE);
@ -151,7 +150,7 @@ public class ExcelHeadProperty {
*/
private boolean initOneColumnProperty(Holder holder, int index, Field field, Boolean forceIndex) {
if (holder instanceof AbstractWriteHolder) {
if (((AbstractWriteHolder)holder).ignore(field.getName(), index)) {
if (((AbstractWriteHolder) holder).ignore(field.getName(), index)) {
return true;
}
}

1
src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java

@ -156,6 +156,7 @@ public class ExcelWriteAddExecutor extends AbstractExcelWriteExecutor {
boolean uselessData = !beanMap.containsKey(filedName) || beanMapHandledSet.contains(filedName)
|| ignoreMap.containsKey(filedName) || writeContext.currentWriteHolder().ignore(filedName, cellIndex);
if (uselessData) {
cellIndex++;
continue;
}
Object value = beanMap.get(filedName);

1
update.md

@ -8,6 +8,7 @@
* 修复xls仅公式行 不读取的bug [Issue #1324](https://github.com/alibaba/easyexcel/issues/1324)
* 修复xls直接读取第2页 `NPE` 的bug [Issue #1280](https://github.com/alibaba/easyexcel/issues/1280)
* 修复填充的时候,最后一行中间有空行会创建失败的bug
* 修复`includeColumnIndexes`不包含第列 会无法导出数据的bug [Issue #1346](https://github.com/alibaba/easyexcel/issues/1346)
# 2.2.3
* 修改填充数据空数据的bug [Issue #1274](https://github.com/alibaba/easyexcel/issues/1274)

Loading…
Cancel
Save