Skip to content

Commit

Permalink
Merge e4f8a12 into 74851c8
Browse files Browse the repository at this point in the history
  • Loading branch information
samhalpa committed Jul 26, 2017
2 parents 74851c8 + e4f8a12 commit 772613c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
p2o.iml
target/
poiji.iml
17 changes: 15 additions & 2 deletions src/main/java/com/poiji/internal/marshaller/Unmarshaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ public <T> List<T> deserialize(Class<T> type, PoijiOptions options) {

if (maxPhysicalNumberOfRows > list.size()) {
T t = deserialize0(currentRow, type);
list.add(t);
if (t != null) {
list.add(t);
}
}
}

return list;
}

private <T> T deserialize0(Row currentRow, Class<T> type) {

if (isRowEmpty(currentRow)) {
return null;
}
T instance;
try {
instance = type.newInstance();
Expand Down Expand Up @@ -132,4 +136,13 @@ private Object castValue(Class<?> fieldType, String value) {
private boolean skip(final Row currentRow, int skip) {
return currentRow.getRowNum() + 1 <= skip;
}

private boolean isRowEmpty(Row row) {
for (int c = row.getFirstCellNum(); c < row.getLastCellNum(); c++) {
Cell cell = row.getCell(c, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK)
return false;
}
return true;
}
}

0 comments on commit 772613c

Please sign in to comment.