Bug 40028 - NaN Cell Value appears as 3.48484087130803E+308
Summary: NaN Cell Value appears as 3.48484087130803E+308
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-12 12:17 UTC by Rodrigo Vega
Modified: 2008-05-05 19:43 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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);
}