No need to apologise for asking a question. Once, I was told that the only stupid question is the one you do not ask and always try to abide by that.
Anyway, at the risk of boring the pants off of you, there is really no such thing as a date cell in Excel. What you see as a date is actually a specially formatted number and so the call to getCellType() will tell you that the cell is - quite rightly - a numeric one. As a result, there is a method in the DateUtil class (org.apache.poi.ss.usermodel.DateUtil) that will tell you whether the user has formatted the cell to look like a date. As a result, when dealing attempting to work out what the cells contain, most users of the API do something like this; Row row = sheet.getRow(1); Cell cell = row.getCell(1); switch(cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: if(DateUtil.isDateFormatted(cell)) { // Get the cells contents as a Date as we now know // that it contains a date value cell.getDateValue(); } else { // The cell contains a number so get that cell.getNumericCellValue(); } break; } Hope thathelps and of course I have omitted all of the other cell type checks in the switch statement above. Yours Mark B ljnelson wrote: > > Cell#getType() doesn't return an int constant identifying a date. > > There's a Cell#getDateCellValue() method. > > How do I know when it's OK to call this? For everything else I can switch > off the cell type. > > I'm using POI 3.6. > > Sorry for the newbie question. > > Laird > > -- View this message in context: http://old.nabble.com/Cell-date--tp28909311p28910865.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@poi.apache.org For additional commands, e-mail: user-h...@poi.apache.org