poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MSB <markbrd...@tiscali.co.uk>
Subject Re: identifying the date cell
Date Tue, 12 Jan 2010 16:20:55 GMT

No, there is no other way. The reason is that dates are actually stored as
numbers - long integers I think - and then formatted so that the user of the
worksheet sees a date in the format most familiar to them. That is why there
is a need for the second check; knowing that the cell contains a number is
not enough, it is necessary to look at the format applied to the cell to
determine if it contains a date or not.

Yours

Mark B


VK123 wrote:
> 
> I am using the POI version 3.5. I want to identify a Cell is a date 
> formatted cell. I was looking at the interface 
> org.apache.poi.ss.usermodel.Cell 
> which is not having a field to identify a date formatted cell. 
> 
> When I tried the below code 
> 
> CellReference cellReference = new CellReference("A5");
> Row row = sheet.getRow(cellReference.getRow());
> Cell cell = row.getCell(cellReference.getCol());
> int cellFormat = cell.getCellType();
> 
> the value of the cellFormat is 0 for both numeric and date fields. 
> 
> But I can alternativley identify a date cell by using below code 
> 
> if(cellFormat == CELL.CELL_TYPE_NUMERIC) {
>     if(DateUtil.isCellDateFormatted(cell)) {
>         //Date cell 
>     } else {
>        //Numeric cell
>     }
> }
> 
> but is there a way to check the date cell straight away with out calling 
> the DateUtil class.
> 
> 
> Regards,
> 
> Vijayakumar Gowdaman
> 
> 
> ---
> 
> This e-mail may contain confidential and/or privileged information. If you
> are not the intended recipient (or have received this e-mail in error)
> please notify the sender immediately and delete this e-mail. Any
> unauthorized copying, disclosure or distribution of the material in this
> e-mail is strictly forbidden.
> 
> Please refer to http://www.db.com/en/content/eu_disclosures.htm for
> additional EU corporate and regulatory disclosures.
> 

-- 
View this message in context: http://old.nabble.com/identifying-the-date-cell-tp27125003p27130100.html
Sent from the POI - User mailing list archive at Nabble.com.


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


Mime
View raw message