Thanks for the reply Mark. That's exactly I am doing in my code.
Once it is a number then I am using a getDataFormatString() to get the format of the date. Regards, Vijayakumar Gowdaman Group Technology & Operations (GTO) Global Markets Deutsche Bank off: 02075456250 Mob:07789773998 MSB <[email protected]> 12/01/2010 16:20 Please respond to "POI Users List" <[email protected]> To [email protected] cc Subject Re: identifying the date cell 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: [email protected] For additional commands, e-mail: [email protected] --- 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.
