I'm trying to read numbers from an Excel spreadsheet. 
The cells containing the numbers are formatted as
General, and have no specification of the number of
decimal places, yet when I read the cell using
cell.getNumericCellValue(), I get a different number
of decimal places than what is shown in Excel.  For
instance, one cell contains the value 30.69677419 in
Excel, yet displays as 30.69677419354839 when
retrieved using POI.

Here's the code that I'm using to retrieve the cell
values:

        //  Allow for the biggest possible number we might
ever get
    DecimalFormat df = new
DecimalFormat("####################.####################")
;
        if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING)
{
            String cellValue =
cell.getStringCellValue().trim() ;
        }
        else if (cell.getCellType() ==
HSSFCell.CELL_TYPE_NUMERIC) {
           
rowValues.add(df.format(cell.getNumericCellValue())) ;
        }

Can anyone explain why the differences are occurring,
and what we can do to display the data in the way it
is shown in Excel (which is what the users expect) ? 
I know that I could round it to a specific number of
decimal places, but we want the users to be able to
put in an arbitrary number of decimal places in a cell
in the spreadsheet and have the program retrieve them
as entered.


Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

Reply via email to