poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Burch <nick.bu...@alfresco.com>
Subject Re: Getting Decimal Instead of Text String
Date Sat, 04 Jun 2011 06:05:50 GMT
On Fri, 3 Jun 2011, eugenebalt wrote:
> I have a cell in my spreadsheet that looks like "115". I verified that it is
> formatted as "Text" (Format Cells -> Text).
> However, when I read it in as
> row.getCell(0).toString()
> I get this string: "115.0"

Formatted as text does not mean stored as text, they're different. Excel 
has stored your cell as a number, and when you ask POI for the cell you 
get a numeric cell back.

If you ask the cell you get back what type it is, you'll discover it's of 

What you'll likely want to do is use the DataFormatter class to have your 
cell formatted as per Excel. It'll then look like you expect. (As will 
cells formatted as currency, percentages etc too)


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

View raw message