Skip to content

Commit

Permalink
Fix null string cell bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Feliciano Long committed Jun 4, 2016
1 parent d9d1327 commit e640cfe
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/moe/imvery/utils/xlsx2json/ExcelParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Iterator;

import static org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK;
import static org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING;

/**
* Created by Feliciano on 6/1/2016.
Expand Down Expand Up @@ -128,6 +129,13 @@ public static JSONObject parseRow(Row row, ParsedSheet parsedSheet) {
// Null cell handler
switch (type) {
case BASIC:
// Handle "Null" string
if (cell != null && cell.getCellType() == CELL_TYPE_STRING) {
if (cell.getStringCellValue().equalsIgnoreCase("null")) {
jsonRow.put( key, JSONObject.NULL);
continue;
}
}
case OBJECT:
if (cell == null || cell.getCellType() == CELL_TYPE_BLANK) {
jsonRow.put( key, JSONObject.NULL);
Expand Down

0 comments on commit e640cfe

Please sign in to comment.