Bryan,
Try the following, it works for me:

if (cell.getCellType() == 1) {
                                cellValue = cell.getStringCellValue();
                        } else {
                                cellNumVal = new
Double(cell.getNumericCellValue());
                                cellValue = cellNumVal.longValue() + "";
                        }

Regards,
Garima.

-----Original Message-----
From: Bryan Liu [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 06, 2006 4:16 PM
To: [email protected]
Subject: Big trouble about the cell format when reading the excel file

Hi,

I have a big trouble about the excel cell's format.
In my project, I readed the data from the excel file. For one column, it
supposed to be String format and I alse set the format as text in the
Excel.
But in some  cells in this column, all the character is number(like this
"51231341"). When I read them in the java code, the poi read these data
as
double, and if I transfer them in to string, it will show as this "
5.1231341E7". This is not the data I want.
Thought I have resolved this problem by reformat this kind of stupid
String.
By I'd like to know if I can read the data follow the Excel's format or
I
can specify the format that I want when read the data from file.

Dose the POI have this kind of feature.
Thanks

--

Regards!
Bryan.Liu

****************************************************************************************

Note:  If the reader of this message is not the intended recipient, or an 
employee or agent responsible for delivering this message to the intended 
recipient, you are hereby notified that any dissemination, distribution or 
copying of this communication is strictly prohibited. If you have received this 
communication in error, please notify us immediately by replying to the message 
and deleting it from your computer. Thank you.

****************************************************************************************

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

Reply via email to