Date cells

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Date cells

Luce, Marc
I am trying to read an excel file and I am struggling with Date fields.  I have a column that has a custom date format applied to the whole column and there is no data in it.  When I attempt to read this column (cell.getDateCellValue()) I would expect it to return null.  But it is returning today's date.  By the way, getCellType returns 'Numeric'.  Is there anyway for me to detect that that cell is empty?

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

Reply | Threaded
Open this post in threaded view
|

RE: Date cells

Amol Deshmukh
Marc,

Normally if the cell were not containing any data,
I would expect it to be null or of type "blank".

So could you post the relevant code snippet?

Also, maybe you should run the code against
another xls file that has an empty column with date
format (I did that and the cell was returned as null)


~ amol




> -----Original Message-----
> From: Luce, Marc [mailto:[hidden email]]
> Sent: Wednesday, May 25, 2005 10:06 AM
> To: [hidden email]
> Subject: Date cells
>
>
> I am trying to read an excel file and I am struggling with
> Date fields.  I have a column that has a custom date format
> applied to the whole column and there is no data in it.  When
> I attempt to read this column (cell.getDateCellValue()) I
> would expect it to return null.  But it is returning today's
> date.  By the way, getCellType returns 'Numeric'.  Is there
> anyway for me to detect that that cell is empty?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>

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

Reply | Threaded
Open this post in threaded view
|

AW: Date cells

KHZ (SAW)
Hi Amol.

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.

About empty cells read the thread "reading empty cells" in the archive
(in November 2003).

Regards, Karl-Heinz.


-----Urspr√ľngliche Nachricht-----
Von: Amol Deshmukh [mailto:[hidden email]]
Gesendet: Mittwoch, 25. Mai 2005 18:17
An: 'POI Users List'
Betreff: RE: Date cells

Marc,

Normally if the cell were not containing any data,
I would expect it to be null or of type "blank".

So could you post the relevant code snippet?

Also, maybe you should run the code against
another xls file that has an empty column with date
format (I did that and the cell was returned as null)


~ amol




> -----Original Message-----
> From: Luce, Marc [mailto:[hidden email]]
> Sent: Wednesday, May 25, 2005 10:06 AM
> To: [hidden email]
> Subject: Date cells
>
>
> I am trying to read an excel file and I am struggling with
> Date fields.  I have a column that has a custom date format
> applied to the whole column and there is no data in it.  When
> I attempt to read this column (cell.getDateCellValue()) I
> would expect it to return null.  But it is returning today's
> date.  By the way, getCellType returns 'Numeric'.  Is there
> anyway for me to detect that that cell is empty?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>

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




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

Reply | Threaded
Open this post in threaded view
|

RE: Date cells

Luce, Marc
In reply to this post by Luce, Marc
Thanks.  When I pasted the code snippet in the response I saw a BONEHEAD mistake.  That fixed it.  Thanks.  Sorry to bother you all.

-----Original Message-----
From: Amol Deshmukh [mailto:[hidden email]]
Sent: Wednesday, May 25, 2005 12:17 PM
To: 'POI Users List'
Subject: RE: Date cells


Marc,

Normally if the cell were not containing any data,
I would expect it to be null or of type "blank".

So could you post the relevant code snippet?

Also, maybe you should run the code against
another xls file that has an empty column with date
format (I did that and the cell was returned as null)


~ amol




> -----Original Message-----
> From: Luce, Marc [mailto:[hidden email]]
> Sent: Wednesday, May 25, 2005 10:06 AM
> To: [hidden email]
> Subject: Date cells
>
>
> I am trying to read an excel file and I am struggling with
> Date fields.  I have a column that has a custom date format
> applied to the whole column and there is no data in it.  When
> I attempt to read this column (cell.getDateCellValue()) I
> would expect it to return null.  But it is returning today's
> date.  By the way, getCellType returns 'Numeric'.  Is there
> anyway for me to detect that that cell is empty?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>

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


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