You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2018/02/09 14:04:31 UTC

[Bug 61495] FormulaEvaluator does evaluate Number wrong. [=TEXT(nr;FORMAT)]

https://bz.apache.org/bugzilla/show_bug.cgi?id=61495

L.Dag <l....@outlook.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|3.16-FINAL                  |3.17-FINAL

--- Comment #2 from L.Dag <l....@outlook.de> ---
Hello again,
I did HOTFIX this problem for my usecase, however i think that this still
should be adressed since it is a bug after all.
The Hotfix is made by before reading in anything from the Workbook, i do parse
every Formula Cell and replace the "0,00" to a "0.00" so the FormulaEvaluator
can operate as intended.

#####ACTUAL_CODE######

/**
 * @author l.dag
 * 
 * searches Each Sheet, Row and Cell for Formulas with "0,00"(=German standard)
and replaces with "0.00"(=US standard)
 *
 */
public static void repairFormulas(final Workbook wb) {
  wb.sheetIterator().forEachRemaining(sheet ->
IntStream.range(sheet.getFirstRowNum(), sheet.getLastRowNum()).filter(i ->
sheet.getRow(i)!=null).mapToObj(sheet::getRow)
  .flatMap(r -> IntStream.range(r.getFirstCellNum(),
r.getLastCellNum()).filter(i -> r.getCell(i)!=null).mapToObj(r::getCell))
  .filter(c -> Cell.CELL_TYPE_FORMULA == c.getCellType() &&
c.getCellFormula().contains("\"0,00\"")).forEach(c ->
c.setCellFormula(c.getCellFormula().replace("\"0,00\"", "\"0.00\""))));
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org