You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Martin Bradley <ma...@btinternet.com> on 2006/06/19 21:22:17 UTC

Reading leading zero formatted numbers

Folks,

I've been using POI to read values from excel spreadsheets, but I have a problem.

My spreadsheets can contain a column with the following codes shown in the table.  The formatting of the cells is set up as Custom 0000000

0003322
0047345
7088449
7145456
2380398
0234400

I do know that the column should be set to Text, since that is what it contains, these are not numbers but codes.  However I have no control over this since I have not created the data.

Whenever I read the values out of the cells I get the following doubles.

3322.0
47345.0
7088449.0
7145456.0
2380398.0
234400.0

POI is reading the correct value from the sheet, the values read are the same as the ones shown in the Formula bar whenever the cell is selected.  The Excel application is taking the Formatting preference and displaying the leading zeros to the user.

How can I get POI to read the values that are shown in the table after the formatting has been applied.  I want the String 
0003322 for the first cell for example.

I'm sure that this is not the first time this problem came up, I've searched the mailing list archive but only seen people trying to preserve the leading zero when writing Excel sheets.

thanks for your time,
Martin.


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