Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getDateCellValue not working as desired. #14

Closed
rupeshpadhye opened this issue Sep 22, 2015 · 3 comments
Closed

getDateCellValue not working as desired. #14

rupeshpadhye opened this issue Sep 22, 2015 · 3 comments
Milestone

Comments

@rupeshpadhye
Copy link

I am reading an excel's column whose format is Date.
row.getCell(54).getCellType() -->(showing 3)
row.getCell(54).getDateCellValue() ;
giving me Following Runtime Exception.
Exception in thread "main" java.lang.NullPointerException
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1838)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.lang.Double.parseDouble(Double.java:538)
at com.monitorjbl.xlsx.impl.StreamingCell.getNumericCellValue(StreamingCell.java:130)
at com.monitorjbl.xlsx.impl.StreamingCell.getDateCellValue(StreamingCell.java:143)

@monitorjbl
Copy link
Owner

Judging from the stacktrace, the cell value is null when that error occurs. There should always be an error in that case (though it could certainly be made clearer). Are you sure the sheet has a value there? If so, can you post an example file?

@rupeshpadhye
Copy link
Author

Yes you are correct .The cell value is empty.So how one can handle this scenario.I think currently this method is not able to handle null condition.

@monitorjbl
Copy link
Owner

Looks like the way I wrote this technically violates the terms of the interface:

java.util.Date getDateCellValue()
    Get the value of the cell as a date. For strings we throw an exception. For blank cells we return a null.

double getNumericCellValue()
    Get the value of the cell as a number. For strings we throw an exception. For blank cells we return a 0. For formulas or error cells we return the precalculated value;

So, it should just return a null unless the value is not parseable.

monitorjbl added a commit that referenced this issue Nov 13, 2015
Returning null on blank cells when calling getDateCellValue() (#14)
@monitorjbl monitorjbl modified the milestone: 0.2.10 Nov 13, 2015
rimuln referenced this issue in rimuln/excel-streaming-reader Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants