You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Albert Wang <Al...@bms.com> on 2003/01/02 20:44:41 UTC

reading numeric cell values as Strings

Hi all,

I found variations of my question in the mailing list archives, so I 
apologize if this is redundant, but I couldn't find the exact answer I 
was looking for:

I'm trying to read in an Excel spreadsheet (created outside of HSSF), 
and I'd like all cells to be read as Strings, exactly as they are 
displayed, including numbers.  In the spreadsheet, I have set the format 
of all cells to be Text.  I assumed HSSF would then determine the cell 
type of all cells to be String, but apparently that's not the case: if 
the cell contains only numeric characters, HSSF seems to decide it's 
Numeric.  Am I doing something wrong?  Is there some way to accomplish 
what I'm looking for?

Thanks,
-Al

-- 



Re: reading numeric cell values as Strings

Posted by "Andrew C. Oliver" <ac...@apache.org>.
HSSF didn't decide.  Excel did.  java.text.NumberFormat converts. 
 (There are tutorials on how to use that I think on java.sun.com)
you can probably *nearly* use the HSSFCellFormat strings to format it. 
 They differ slightly from the Java ones...but I think I've used them
before.

Albert Wang wrote:

> Hi all,
>
> I found variations of my question in the mailing list archives, so I 
> apologize if this is redundant, but I couldn't find the exact answer I 
> was looking for:
>
> I'm trying to read in an Excel spreadsheet (created outside of HSSF), 
> and I'd like all cells to be read as Strings, exactly as they are 
> displayed, including numbers.  In the spreadsheet, I have set the 
> format of all cells to be Text.  I assumed HSSF would then determine 
> the cell type of all cells to be String, but apparently that's not the 
> case: if the cell contains only numeric characters, HSSF seems to 
> decide it's Numeric.  Am I doing something wrong?  Is there some way 
> to accomplish what I'm looking for?
>
> Thanks,
> -Al
>