Unfortunately, I am not completely clear about the question you are asking. I
understand that the value of a numeric cell is always recovered - using the
getNumericCellValue() method as a double so - even if the cell contained the
integer value 2 you will recover the double value 2.0. Are you asking how to
recover the value exactly as the user would see it displayed in the cell on
the sheet? If so then look at the HSSFDataFormatter class; this class has
methods that apply the cells formatting string to the value you recover from
the cell.

The disadvantage of using this class is that the formatCellValue() method
always returns a String value. This will not matter if all you need the data
for is to display on a report but it could if you intend to use the value in
a calculation. If you need to included the recovered, formatted value in a
calculation then after calling the formatCellValue() method, you will need
to convert the String back into a number - luckily Java has, as I am sure
you know, methods to parse Strings into integer or double values.

Finally, it is far better to post these sorts of questions in the User
llist. As I use Nabble, I look at both lists but most users will only visit
one and, if you do not post there, you are limiting the number of people who
could respond to your question.


Bugzilla from [email protected] wrote:
> 
> https://issues.apache.org/bugzilla/show_bug.cgi?id=46728
> 
>            Summary: When I get the cellValue '2', but I get '2.0'?
>            Product: POI
>            Version: 3.2-FINAL
>           Platform: PC
>         OS/Version: Windows XP
>             Status: NEW
>           Severity: normal
>           Priority: P2
>          Component: HSSF
>         AssignedTo: [email protected]
>         ReportedBy: [email protected]
> 
> 
> when I want get the cell value(number), how can i judge the real cell
> value is
> '2' or is '2.0'?
> 
> 
> -- 
> Configure bugmail:
> https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are the assignee for the bug.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/DO-NOT-REPLY--Bug-46728--New%3A-When-I-get-the-cellValue-%272%27%2C-but-I-get-%272.0%27--tp22070617p22073635.html
Sent from the POI - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to