https://issues.apache.org/bugzilla/show_bug.cgi?id=51339
--- Comment #4 from Yegor Kozlov <[email protected]> 2011-06-08 12:02:34 UTC --- Firstly, you didn't provide enough information to research the problem. The attached file contains a Maven project which actually consists of the following code: InputStream is = new FileInputStream("c:\\excelbugs\\bug.xlsm"); XSSFWorkbook wb = new XSSFWorkbook(is); FormulaEvaluator poiEvaluator = wb.getCreationHelper().createFormulaEvaluator(); CellValue cellValue = poiEvaluator.evaluate(wb.getSheet("Sheet1").getRow(0).getCell(2)); System.out.println("Value is " + cellValue.getNumberValue()); If you assert results from a file, please attach that file too. Secondly, it is not a bug in POI, rather a way it performs the floating-number math. POI performs strict 'Double' arithmetics while Excel seems to use a mixed BigDecimal / Double. By 'mixed' I mean that for most formulas Excel uses 'double' math and for some formulas it *may* use BigDecimal, in particular, for financial functions. How do you assert the results? In Excel you see 275,62 which is a formatted value. The evaluator returns 275,61 with some trailing flowing points. How do you compare these two values? Hint: To get a formatted value in Java you should call DataFormatter#formatCellValue(Cell cell). Yegor (In reply to comment #2) > Yeah i know that i can fix this by modifing an excel formulas but this is not > the case. If excel is hiding it for me, why POI cant just do the same ? > I already broke a problem down and provided a simple sumimg which shows this > buggy effect. -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
