poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krishna81m <krishna...@gmail.com>
Subject What is the correct way of preserving decimal precision while entering and saving Big Decimal values using Apache POI
Date Fri, 26 Feb 2010 05:11:30 GMT

When I create a HSSFCell out of a BigDecimal, the only way to save it is, via
cell.setCellValue(bigDecimalValue.doubleValue())

when this cell is read as new
BigDecimal(row.getCell(index).getNumericCellValue())

this bigDecimal value appears wrong!
25.9607 becomes 25.96069999999999

If the whole of the above process is repeated with 
cell.setCellValue(bigDecimalValue.toString())

and cell is read as new BigDecimal(row.getCell(index).getStringCellValue())

everything works fine. What is going wrong here and what is the best
practice to persist a BigDecimal number using Apache HSSF POI, what about
the importance of cell style and format?

-- 
View this message in context: http://old.nabble.com/What-is-the-correct-way-of-preserving-decimal-precision-while-entering-and-saving-Big-Decimal-values-using-Apache-POI-tp27714660p27714660.html
Sent from the POI - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message