You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Mike Wertheim <mi...@linkify.com> on 2004/12/22 21:33:00 UTC

When is an HSSFCell a date?

Hi all,

I'm new to the list.  I've been a poi user for a year and have been
loving it.

I need to parse some date fields from an xls file, and am a bit
confused.  It seems that if a cell contains a date,
HSSFCell.getCellType() returns CELL_TYPE_NUMERIC.  If I know in advance
that the cell contains a date, I can easily convert the returned number
into a date.  But if I don't know in advance what is in the cell, how
can I determine if the cell is a date or not?

Is this something that the file format make particularly difficult, or
is it a poi implementation issue?


Thanks!

-Mike Wertheim
www.linkify.com




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


AW: When is an HSSFCell a date?

Posted by "KHZ (SAW)" <ka...@sawag.com>.
Hi Mike.

Dates come as numeric data. You've methods like getDateCellValue()
(class HSSFCell) and HSSFDateUtil.isCellDateFormatted() and
HSSFDateUtil.isValidExcelDate() to read it as a date or to check whether
it's date formatted.

In case of formula you just have a cell type formula. In that case you
either know the type of its content or you've to guess its type and take
the most reasonable value (the one different from being empty). Guessing
the wrong type doesn't result in an exception. It returns an empty value
of the result type then.

Regards,	Karl-Heinz.


-----Ursprüngliche Nachricht-----
Von: Mike Wertheim [mailto:mike.wertheim@linkify.com] 
Gesendet: Mittwoch, 22. Dezember 2004 21:33
An: poi-user@jakarta.apache.org
Betreff: When is an HSSFCell a date?


Hi all,

I'm new to the list.  I've been a poi user for a year and have been
loving it.

I need to parse some date fields from an xls file, and am a bit
confused.  It seems that if a cell contains a date,
HSSFCell.getCellType() returns CELL_TYPE_NUMERIC.  If I know in advance
that the cell contains a date, I can easily convert the returned number
into a date.  But if I don't know in advance what is in the cell, how
can I determine if the cell is a date or not?

Is this something that the file format make particularly difficult, or
is it a poi implementation issue?


Thanks!

-Mike Wertheim
www.linkify.com




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




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