You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. prepare an excel sheet called "test" with a table like :
| Name | Age |
| Lilly | 18 |
| Jane | |
| Tom | 19 |
2. call PoiExcelUtil.getExcelDataAsMap(filePath, test); (test is sheetName)
3. run it
Expected behavior
read data from an excel file and return it as an object[][].
Actual behavior
return NullPointerException
Is the issue reproducible on runner?
Yes
QAS
Maven
Gradle
Ant
Eclipse
Intellij IDEA
Test case sample
Read data from the file and verify its size is not zero.
The text was updated successfully, but these errors were encountered:
I think exception comes from this method:
+++++++++++++++++++++++++++++++
public static Object getCellContent(Cell cell) {
if (cell != null) {
FormulaEvaluator evaluator = cell.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
CellValue cellValue = evaluator.evaluate(cell);
...}}
+++++++++++++++++++++++++++++++ cellValue will be null if there is no content in cell. When we call cellValue.getCellType() later, It will throw NullPointerException.
But getCellContentAsString() method has handled it.
+++++++++++++++++++++++++++++++
public static String getCellContentAsString(Cell cell) {
if (cell != null) {
FormulaEvaluator evaluator = cell.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
CellValue cellValue = evaluator.evaluate(cell);
if (cellValue == null) {
return "";
} else {
...}..}
+++++++++++++++++++++++++++++++
I'm thinking if there is no value in cell, shall we handle it and return null or empty string?
- used same implementation for xls and xlsx
- removed old implementation ExcelUtil
- #342 for cell with string (Text or @) format, considering empty cell
value as empty string. Null for others including no format (General)
Related to #386, #339, #269
QAF Version
3.0.1b
Steps To Reproduce
Expected behavior
read data from an excel file and return it as an object[][].
Actual behavior
return NullPointerException
Is the issue reproducible on runner?
Yes
Test case sample
The text was updated successfully, but these errors were encountered: