poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Charlat, Simon (Exchange)" <schar...@bear.com>
Subject RE: How to get "12345" to be a real string?
Date Mon, 03 Feb 2003 21:08:17 GMT
I format the cell as text and it works.
cs2.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
Simon.


 -----Original Message-----
From: 	Andy Lee [mailto:aglee@earthlink.net] 
Sent:	Monday, February 03, 2003 3:57 PM
To:	poi-user@jakarta.apache.org
Subject:	How to get "12345" to be a real string?

I put a string into an HSSFCell like this:

     cell.setCellType(HSSFCell.CELL_TYPE_STRING);
     cell.setCellValue("12345");

I open the spreadsheet in Excel and the 12345 looks like a string -- 
left justified, like I wanted...

...BUT  when I double-click the cell to edit it, it has no leading 
apostrophe.  Therefore if I hit Return, or click out of the cell, it 
becomes a number, even though I didn't really change anything.

It seems like there might be a bug in how HSSF stores the cell value. 
Is there a workaround for this (or am I missing the correct way to do 
it)?  I really need the string to stay a string.  I cannot have a 
credit card number like "3141592653589793" suddenly becoming 
"3.14159E+16".  (Yes, that is pi; yes, I am a geek. ;))

I have tried 1.5.1-final and 1.8.0-dev versions of HSSF.  I found 
some related postings in the archives, but none that answered this 
exact question.

--Andy

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


***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation, 
offer or agreement or any information about any transaction, customer 
account or account activity contained in this communication.
***********************************************************************


Mime
View raw message