0
votes

I have an excel file that has formulas in some cells and some input fields based on which value is being computed in the Formula Cell.

After setting the values in the respective cells using apache poi setCellValue() The Values are being set in the excel. This part is working. Then I am running

FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
evaluator.evaluate(cell);

where the cell is the place where I have the formula and also it has some pre-computed value.

My problem was that, after running the FormulaEvaluator when I am fetching the cell value using cell.getNumericCellValue() it is fetching me the pre-computed or older cell value instead of new computed values from the new values set in the cells.

1

1 Answers

1
votes

I think you're expecting another behaviour than the method provides:

Using FormulaEvaluator.evaluate(Cell cell)

This evaluates a given cell, and returns the new value, without affecting the cell

You might want to check if evaluateFormulaCell or evaluateInCell better fit your requirements.

See also the documentation at http://poi.apache.org/components/spreadsheet/eval.html