You can use HSSFCel object to get the data type, if
its string string you done. If its other types numeric
it may be date number etc you can formatit.

I used this code to deal with dates numerics:

{
case HSSFCell.CELL_TYPE_STRING:
        cl = cell.getStringCellValue();
break;                                                  case
HSSFCell.CELL_TYPE_NUMERIC:                             icl =
cell.getNumericCellValue();
        if (isCellDateFormatted(cell))                          {
                                        // format in form of
M/D/YY
                                                            Calendar cal =
Calendar.getInstance();
                                                           
cal.setTime(getJavaDate(icl,false));
                                                            String pattern =
getCellDateFormat(cell);
                                                            SimpleDateFormat
df = new SimpleDateFormat(pattern);
                                                            String dateStr =
df.format(cal.getTime());
                                                    
                        }
                                                        else
String dateStr =  Double.toString(icl));
                                                break;
--- Ilya Kasnacheev <[EMAIL PROTECTED]> wrote:

> I'm using POI HSSF, and I need to dump Excel file
> into XML.
> 
> I've wrote most of it, but still have one problem
> unresolved:
> I'm looking for a way to get numeric cells' content
> as a string, formatted 
> exactly as they would be displayed by Excel itself.
> I mean, date 38629 in "DD.MM.YYYY" should yield
> "04.10.2005", and 2.25 in 
> "# ?/?" should yield "2 1/4".
> 
> I haven't found a way to do that, and googling
> redirects me into 
> HSSFDataFormat which is unrelated, I fail to form a
> relevant query.
> 
> Is there a way do get that string representation? Is
> it already stored in 
> Excel files with possibility to retrieve? Or maybe
> there's a formatter 
> somewhere which I've overlooked? A converter from
> HSSF format to Java's 
> NumberFormat and DateFormat (even if not universal)?
> 
> Maybe any third-party solutions? I guess this
> problem should be pretty 
> popular.
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 



       
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! 
FareChase.
http://farechase.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to