I have an excel file which has a couple of String datatype columns, one numeric column and one date column. Am using Apache POI to read the file. Below is how am handling the datatypes
Cell cell = sheet.getRow(i).getCell(j);
if(cell!=null){
switch(cell.getCellType()){
case Cell.CELL_TYPE_STRING:
cellValue = cell.getStringCellValue();
break;
case Cell.CELL_TYPE_NUMERIC:
DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
Date cellDate = cell.getDateCellValue();
cellValue = df.format(cellDate);
break;
case Cell.CELL_TYPE_BLANK:
break;
default :
}
}
This works fine with String and date datatypes. But for numeric, it's converting the value to a date. I know it's because the handling has issues. Can you please advise on how to accommodate handling of both numeric and date datatypes?
Thanks, Sam.