Bug 40028

Summary: NaN Cell Value appears as 3.48484087130803E+308
Product: POI Reporter: Rodrigo Vega <rodrigo.vega.bs.as.arg>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Rodrigo Vega 2006-07-12 12:17:39 UTC
When i try to put into a cell this

<javaCode>
row.createCell((short) 11).setCellValue(productos.getImporte().doubleValue());
</javaCode>

and doubleValue() return zero... in xls appears 3.48484087130803E+308
Comment 1 Rodrigo Vega 2006-07-12 12:36:46 UTC
(In reply to comment #0)
> When i try to put into a cell this
> 
> <javaCode>
> row.createCell((short) 11).setCellValue(productos.getImporte().doubleValue());
> </javaCode>
> 
> and doubleValue() return zero... in xls appears 3.48484087130803E+308
Sorry doubleValue() don't return zero, it return NaN
Comment 2 Josh Micich 2008-05-05 19:43:13 UTC
IEEE NaN is a little bit tricky, and Excel makes a big mess of it.  I believe if you put NaN in a formula (encoding that value in a NumberPtg) Excel will display '#NUM!', which is sort of expected.  Excel seems to get NaN wrong for a (non formula) cell with a plain number value.  

Perhaps the most consistent way to translate the concept of NaN to an Excel cell value would be to set the error code value to '#NUM!'. The following code can do that:
if(Double.isNaN(d)) {
  cell.setCellErrorValue(HSSFErrorConstants.ERROR_NUM);
} else {
  cell.setCellValue(d);
}