I have an xlsx file that I am reading using the <- → Apache POI library.
For example, On some line, I have these cell values:
01-Sep-13 | 15136.00 | Matt | ......
My goal:
Read all cells in rows as String values. But, as I see it, I cannot read 01-Sep-13 as a string, it only represents the Date () type with cell.getDateCellValue ();
1) Can I somehow read 01-Sep-13 as a line: "01-Sep-13"; 2) Can I convert the Date value to a string if I have different date patterns (ddMMyyyy) and (dd-MMM-yy);
code:
When I iterate over rows and cells, the Apache POI parses each cell type:
String normalizeCellType(Cell cell) {
switch (cell.getCellType()) {
case Cell.CELL_TYPE_STRING:
return cell.getRichStringCellValue().getString());
case Cell.CELL_TYPE_NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
Date date = cell.getDateCellValue(); ????????????
System.out.println(date);
} else {
....
}
break;
case Cell.CELL_TYPE_BOOLEAN:
return ....
case Cell.CELL_TYPE_FORMULA:
return ....
default:
System.out.println();
}
}