Showing posts with label Apache POI. Show all posts
Showing posts with label Apache POI. Show all posts

Wednesday, July 24, 2013

Reading and writing date value in excel with Apache POI

This post shows the code snippet on how to read and write java.util.Date object to an excel.
Writing date into excel is easy; 
Reading date value from excel we must make sure the cell type is date to avoid exception.

Reading date value from excel file

Cell cell = row.getCell(i);
Date dateValue = null;
if(cell.getCellType() == cell.CELL_TYPE_NUMERIC) {
    if (DateUtil.isCellDateFormatted(cell)) {
        dateValue = cell.getDateCellValue();
    }
}

LinkWithin

Related Posts Plugin for WordPress, Blogger...