Bug 55473

Summary: DataFormatter.formatCellValue(cell) throws IllegalArgumentException when the format is mm/dd/yyyy;;; and value is 0
Product: POI Reporter: Narayan <narayan1ap>
Component: XSSFAssignee: POI Developers List <dev>
Status: NEEDINFO ---    
Severity: normal CC: narayan1ap, patrickyccheng
Priority: P1    
Version: 3.10-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: A Xlsx file which has first row formatted with custom format mm/dd/yyyy;;; and contains value 0
Java File for reading excel which gives IllegalArgumentException.

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?