poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doz...@gmx.de
Subject Re: HSSFCell returns numeric value instaed of String
Date Thu, 01 Sep 2005 09:45:42 GMT
Hi Digo,

my code is nearly like yours,


if (typ == HSSFCell.CELL_TYPE_NUMERIC) 		
     content.append(cell.getNumericCellValue()  + " ");

if (typ == HSSFCell.CELL_TYPE_STRING)      
     content.append(cell.getStringCellValue() + " "); 

and i try to reconstruct the situation you have!!

7.36132469E8 this form you get because the cell is formated in
this way! And HSSFCell take this in the format, how it is in the
exel file!

But i have a question about the cell numeration!!
I do the numeration that way:

for (int sheetNr = 0; sheetNr < workbook.getNumberOfSheets(); sheetNr++) {
for (int rowNr = sheet.getFirstRowNum(); rowNr <= sheet.getLastRowNum();
rowNr++) {

the Problem is that it miss out rows which first cell is empty!!!
Have anybody an idea?
Also i get an NullPointerException!!!

Bye Derya


> --- Ursprüngliche Nachricht ---
> Von: Digo Chakraverty <chak@hrs.de>
> An: POI Users List <poi-user@jakarta.apache.org>
> Betreff: HSSFCell returns numeric value instaed of String
> Datum: Thu, 01 Sep 2005 10:07:58 +0200
> 
> Hi all,
> 
> when I try to retrieve the values from some cells,
> the returned format confuses me. Maybe you can help.
> 
> 1. In Excel, I formatted all cells as Strings.
> 2. In the code it looks like this:
> 
>   private String convertToString(HSSFCell cell) {
>          String ret = "";
> 
>          if (cell != null)
>          {
>              int type = cell.getCellType();
>              switch (type)
>              {
>              case HSSFCell.CELL_TYPE_BLANK:
>              case HSSFCell.CELL_TYPE_BOOLEAN:
>              case HSSFCell.CELL_TYPE_ERROR:
>              case HSSFCell.CELL_TYPE_FORMULA:
>                  break;
>              case HSSFCell.CELL_TYPE_NUMERIC:
>                  ret = Double.toString(cell.getNumericCellValue());
>                  System.out.println("number: " + ret);
>                  break;
>              case HSSFCell.CELL_TYPE_STRING:
>                  ret = cell.getStringCellValue();
>                  System.out.println("String: " + ret);
>                  break;
>              }
>          }
> 
>          return ret;
>      }
> 
> 
> 3. With Strings, erverything is ok. Values consisting of numbers
> appear as numbers (although I had formatted them as Strings in Excel).
> 4.Furthermore,  A number like 736132469 is displayed as 7.36132469E8
> 
> Any suggestions?
> 
> 
> Thank you very much.
> 
> Regards, Digo
> 
> 
> ---------------------------------------------------------------------
> 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/
> 

-- 
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse für Mail, Message, More +++

---------------------------------------------------------------------
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/


Mime
View raw message