|
Hi, I want to know the text of a particular cell(not the formula).
How do I achieve this using apache poi. I have tried below. private String
evaluateFormulaCell(Cell cell) { FormulaEvaluator
evaluator = workbook.getCreationHelper().createFormulaEvaluator(); CellReference
cellReference = new CellReference(cell.getRowIndex(), cell.getColumnIndex()); Row
row = sheet.getRow(cellReference.getRow()); Cell
formulaCell = row.getCell(cellReference.getCol()); String
textContent = ""; if (formulaCell !=
null) { switch
(evaluator.evaluateFormulaCell(formulaCell)) { case Cell.CELL_TYPE_BOOLEAN: textContent
= String.valueOf(formulaCell.getBooleanCellValue()); break; case Cell.CELL_TYPE_NUMERIC: String.valueOf(formulaCell.getNumericCellValue()); break; case Cell.CELL_TYPE_STRING: String.valueOf(formulaCell.getStringCellValue()); break; case Cell.CELL_TYPE_BLANK: break; case Cell.CELL_TYPE_ERROR: String.valueOf(formulaCell.getErrorCellValue()); break; case Cell.CELL_TYPE_FORMULA: break; } } return textContent; } But I am getting Exception in thread "Main Thread" java.lang.RuntimeException: Could not
resolve external workbook name 'CP.xls'. Workbook environment has not been set
up. Is there any simple way to get the text content of the cell
?
Jigar Naik | Associate Consultant | +91 22 6718 4124 (O) Oracle Financial Services Software Limited Oracle Financial Services Software Limited was formerly i-flex
solutions limited. |
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
