Bug 55473 - DataFormatter.formatCellValue(cell) throws IllegalArgumentException when the format is mm/dd/yyyy;;; and value is 0
Summary: DataFormatter.formatCellValue(cell) throws IllegalArgumentException when the ...
Status: NEEDINFO
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.10-dev
Hardware: PC All
: P1 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-23 18:11 UTC by Narayan
Modified: 2015-11-04 17:34 UTC (History)
2 users (show)



Attachments
A Xlsx file which has first row formatted with custom format mm/dd/yyyy;;; and contains value 0 (8.67 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2013-08-23 18:11 UTC, Narayan
Details
Java File for reading excel which gives IllegalArgumentException. (1.56 KB, text/plain)
2013-09-02 07:01 UTC, Narayan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Narayan 2013-08-23 18:11:05 UTC
Created attachment 30756 [details]
A Xlsx file which has first row formatted with custom format mm/dd/yyyy;;; and contains value 0

DataFormatter.formatCellValue(cell) throws IllegalArgumentException when the format of a cell is is mm/dd/yyyy;;; and value is 0.

Actually df.formatCellValue(cell); this API returns correct date for non zero numbers and negative numbers it returns negactive values But for value 0 for some reason it is throwing IllegalArgumentExeption.
Comment 1 Narayan 2013-09-02 07:01:08 UTC
Created attachment 30792 [details]
Java File for reading excel which gives IllegalArgumentException.
Comment 2 Bodo Wippermann 2013-09-04 18:21:39 UTC
still in 3.10_beta1 

but it seems to be the result of the custom format. it ends up in an empty Format String for the zero value. 

It is mentioned in a comment in the org.apache.poi.ss.usermodel.DataFormatter Class. The comment that it requires refactoring of other code.
Comment 3 Narayan 2013-09-05 03:35:32 UTC
Thanks Bodo. 

We also found a similar issue with the CellFormat. 
If you try to get the cellformat for three consequtive semicolons then array index out of bound exception observed. 

CellFormat.getInstance(";;;");

This format is supported by the MS Excel by the way.
Comment 4 Dominik Stadler 2015-09-13 12:46:18 UTC
In DataFormatter.getFormat() there is some special handling of semicolons which seems to affect this, not sure why this is done this way currently, though, so doesn't seem easy to fix...
Comment 5 Nick Burch 2015-11-04 17:34:32 UTC
There were a few changes to DataFormatter and ;;; formats done after 3.13 was released, would it be possible for someone to retest this with a recent nightly build / recent svn checkout build / 3.14 beta 1 once released?