I am trying to read all the data from a excel file, which also have some formula cell, but i have no idea that which cell is formula cell. how can i read all the values from the cells irrespective of the type of the cell.
My code looks like this
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
while (rows.hasNext()) {
row = (HSSFRow) rows.next();
Iterator cells = row.cellIterator();
while (cells.hasNext()) {
cell = (HSSFCell) cells.next();
if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
ar.add(cell.getStringCellValue());
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
ar.add(cell.getNumericCellValue());
}else if (cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA) {
ar.add(evaluator.evaluateFormulaCell(cell));
} else {
ar.add("");
}
}
}
I am getting the formula cell value as 0