Browse Source

fix issue-2014

pull/2019/head
yizhi 3 years ago
parent
commit
ef4184d520
  1. 11
      src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java

11
src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java

@ -26,9 +26,12 @@ import net.sf.cglib.beans.BeanMap;
* @author jipengfei * @author jipengfei
*/ */
public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener<Map<Integer, CellData>> { public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener<Map<Integer, CellData>> {
private int headSize;
@Override @Override
public void invokeHead(Map<Integer, CellData> cellDataMap, AnalysisContext context) {} public void invokeHead(Map<Integer, CellData> cellDataMap, AnalysisContext context) {
this.headSize = cellDataMap.size();
}
@Override @Override
public void invoke(Map<Integer, CellData> cellDataMap, AnalysisContext context) { public void invoke(Map<Integer, CellData> cellDataMap, AnalysisContext context) {
@ -62,7 +65,8 @@ public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener
(String)ConverterUtils.convertToJavaObject(cellData, null, null, currentReadHolder.converterMap(), (String)ConverterUtils.convertToJavaObject(cellData, null, null, currentReadHolder.converterMap(),
currentReadHolder.globalConfiguration(), context.readRowHolder().getRowIndex(), key)); currentReadHolder.globalConfiguration(), context.readRowHolder().getRowIndex(), key));
} }
int headSize = currentReadHolder.excelReadHeadProperty().getHeadMap().size(); int headSize = currentReadHolder.excelReadHeadProperty().getHeadMap().size() == 0
? this.headSize : currentReadHolder.excelReadHeadProperty().getHeadMap().size();
while (index < headSize) { while (index < headSize) {
map.put(index, null); map.put(index, null);
index++; index++;
@ -87,7 +91,8 @@ public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener
(String)ConverterUtils.convertToJavaObject(cellData, null, null, currentReadHolder.converterMap(), (String)ConverterUtils.convertToJavaObject(cellData, null, null, currentReadHolder.converterMap(),
currentReadHolder.globalConfiguration(), context.readRowHolder().getRowIndex(), key)); currentReadHolder.globalConfiguration(), context.readRowHolder().getRowIndex(), key));
} }
int headSize = currentReadHolder.excelReadHeadProperty().getHeadMap().size(); int headSize = currentReadHolder.excelReadHeadProperty().getHeadMap().size() == 0
? this.headSize : currentReadHolder.excelReadHeadProperty().getHeadMap().size();
while (index < headSize) { while (index < headSize) {
list.add(null); list.add(null);
index++; index++;

Loading…
Cancel
Save