Created attachment 23086 [details] patch a) Create a formula that is invalid e.g. put XXX in A1 and =A1+1 in B1. b) Change the value in A1 to 2.5 c) Call HSSFFormulaEvaluator.evaluateInCell on B1 Actual Result: java.lang.IllegalStateException: Cannot get a numeric value from a error formula cell Expected Result: B1 contains 3.5 POI 3.1 did not have this problem but POI 3.2 and all newer versions including the current trunk do.
Created attachment 23087 [details] testcase
Created attachment 23088 [details] testcase
Thanks for the patch. There is some ambiguity in original design as to whether setCellType() should be called before or after setCellValue(). The methods overlap in behaviour: setCellValue() may change the cell type, and setCellType() converts the old cell value to the new type and sets the new value in the cell. The new ordering of these calls (setCellValue before setCellType) actually causes other junits to fail, but your fix still seems correct to me. Three other related bugs were found and fixed, and junits added for all of them. svn r731715
Additional similar fixes applied in svn r886951 Problems occurred when changing a formula cell to type string. These cases weren't addressed in the previous fix.