You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2016/03/18 15:08:24 UTC
[Bug 59199] New: setting null value to date cell leads to NPE
https://bz.apache.org/bugzilla/show_bug.cgi?id=59199
Bug ID: 59199
Summary: setting null value to date cell leads to NPE
Product: POI
Version: 3.14-FINAL
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
Assignee: dev@poi.apache.org
Reporter: jupp.strunk@gmx.de
When setting a Date value in a cell and the date is null, a
NullPointerException is thrown.
Example:
private void createRow(Sheet sheet, Person person) {
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue(person.getBirthdate());
...
If person.getBirthdate() is null we get a NPE:
java.lang.NullPointerException
at java.util.Calendar.setTime(Calendar.java:1770)
at org.apache.poi.ss.usermodel.DateUtil.getExcelDate(DateUtil.java:76)
at org.apache.poi.xssf.usermodel.XSSFCell.setCellValue(XSSFCell.java:742)
My workaround is to check for null and in this case set
cell.setCellValue((String) null);
However, in my opinion Cell.setCellValue(Date value) should take care of this,
just like Cell.setCellValue(String value)
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59199] setting null value to date cell leads to NPE
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59199
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
OS| |All
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59199] setting null value to date cell leads to NPE
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59199
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #1 from Dominik Stadler <do...@gmx.at> ---
This has been adjusted via r1736923, passing null to setValue() for Date and
Calendar leads to a CELL_TYPE_BLANK similar to how String and RichtTextString
are handled already.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org