I am trying to read a .xls file by JExecel Api. I can read some column data by using cell.getContents() easily. But some column give me mysterious value 1, but column type looks like Date. So i check those column type and Find they are Number Type. So i cast those cell in NumberCell. But output looks still mysterious 1.
Workbook workbook = null;
try {
workbook = Workbook.getWorkbook("StandardReport.xls");
Sheet sheet = workbook.getSheet(0);
Cell[] cellRow = sheet.getColumn(0);
for (int row = 4; row < cellRow.length; row++) {
String id = cellRow[row].getContents().trim();
if (id.isEmpty() == false) {
Cell cell1 = sheet.getCell(1, row);
Cell cell2 = sheet.getCell(2, row);
Cell cell3 = sheet.getCell(3, row);
System.out.println(cell1.getContents()+"");
System.out.println(cell2.getContents()+"");
System.out.println(cell3.getContents()+"");
if (cell3.getType() == CellType.NUMBER) {
NumberCell date=(NumberCell)cell3;
System.out.println(date.getContents()+"");
}
/*if (cell3.getType() == CellType.BOOLEAN) {
System.out.println("2");
}
if (cell3.getType() == CellType.BOOLEAN_FORMULA) {
System.out.println("3");
}
if (cell3.getType() == CellType.DATE_FORMULA) {
System.out.println("4");
}
if (cell3.getType() == CellType.EMPTY) {
System.out.println("5");
}
if (cell3.getType() == CellType.ERROR) {
System.out.println("6");
}
if (cell3.getType() == CellType.FORMULA_ERROR) {
System.out.println("7");
}
if (cell3.getType() == CellType.LABEL) {
System.out.println("8");
}
if (cell3.getType() == CellType.NUMBER) {
System.out.println("9");
}
if (cell3.getType() == CellType.NUMBER_FORMULA) {
System.out.println("11");
}
if (cell3.getType() == CellType.STRING_FORMULA) {
System.out.println("12");
}*/
}
}
} catch (IOException | BiffException ex) {
StaticAccess.showMessageDialog("Failed!!", ex);
}
Here is the file link of StandardReport.xls