Java 公式不';单元格值更改时不工作

Java 公式不';单元格值更改时不工作,java,excel,apache-poi,Java,Excel,Apache Poi,我正在使用POI Excel,我有以下场景: 通过该行代码,我更改A3值,这是一个下拉列表: sheet.getRow(2).getCell(0).setCellValue(uf); 这部分工作正常,我已经确认单元格值已更改 糟糕的是: E7有这样一个公式:=连接($3;D7) 因此,当我使用以下方法更改A3值时: sheet.getRow(2).getCell(0).setCellValue(uf); 应通过公式更改E7值,但这不起作用 我不知道如何使用java中的公式动态更改单元格值 我

我正在使用POI Excel,我有以下场景:

通过该行代码,我更改A3值,这是一个下拉列表:

sheet.getRow(2).getCell(0).setCellValue(uf);
这部分工作正常,我已经确认单元格值已更改

糟糕的是:

E7有这样一个公式:=连接($3;D7)

因此,当我使用以下方法更改A3值时:

sheet.getRow(2).getCell(0).setCellValue(uf);
应通过公式更改E7值,但这不起作用

我不知道如何使用java中的公式动态更改单元格值


我认为这应该可以自己解决。就像我手动更改了A3值一样。

在Apache POI中,当值更改时,Excel公式不会自动重新计算

更改完公式中引用的任何单元格的值后,请创建一个
FormulaEvaluator
,并告诉它使用计算所有公式

或者,您可以通过使用设置适当的标志,强制Excel在打开时重新计算公式


在ApachePOI中,当值更改时,Excel公式不会自动重新计算

更改完公式中引用的任何单元格的值后,请创建一个
FormulaEvaluator
,并告诉它使用计算所有公式

或者,您可以通过使用设置适当的标志,强制Excel在打开时重新计算公式


在ApachePOI中,当值更改时,Excel公式不会自动重新计算

更改完公式中引用的任何单元格的值后,请创建一个
FormulaEvaluator
,并告诉它使用计算所有公式

或者,您可以通过使用设置适当的标志,强制Excel在打开时重新计算公式


在ApachePOI中,当值更改时,Excel公式不会自动重新计算

更改完公式中引用的任何单元格的值后,请创建一个
FormulaEvaluator
,并告诉它使用计算所有公式

或者,您可以通过使用设置适当的标志,强制Excel在打开时重新计算公式

我会建议你怎么做

evaluator.clearAllCachedResultValues()
在使用evaluator执行任何操作之前(如果不是现在创建的)

Javadoc:

/**
 * Should be called whenever there are changes to input cells in the evaluated workbook.
 * Failure to call this method after changing cell values will cause incorrect behaviour
 * of the evaluate~ methods of this class
 */
在评估之前使用该行,即使在错误的公式上,evaluator也能正常工作。

我建议这样做

evaluator.clearAllCachedResultValues()
在使用evaluator执行任何操作之前(如果不是现在创建的)

Javadoc:

/**
 * Should be called whenever there are changes to input cells in the evaluated workbook.
 * Failure to call this method after changing cell values will cause incorrect behaviour
 * of the evaluate~ methods of this class
 */
在评估之前使用该行,即使在错误的公式上,evaluator也能正常工作。

我建议这样做

evaluator.clearAllCachedResultValues()
在使用evaluator执行任何操作之前(如果不是现在创建的)

Javadoc:

/**
 * Should be called whenever there are changes to input cells in the evaluated workbook.
 * Failure to call this method after changing cell values will cause incorrect behaviour
 * of the evaluate~ methods of this class
 */
在评估之前使用该行,即使在错误的公式上,evaluator也能正常工作。

我建议这样做

evaluator.clearAllCachedResultValues()
在使用evaluator执行任何操作之前(如果不是现在创建的)

Javadoc:

/**
 * Should be called whenever there are changes to input cells in the evaluated workbook.
 * Failure to call this method after changing cell values will cause incorrect behaviour
 * of the evaluate~ methods of this class
 */

在评估之前使用该行,evaluator即使在错误的公式上也能正常工作。

它不应该以这种方式工作。使用clearAllCachedResultValues();听着,不应该这样。使用clearAllCachedResultValues();听着,不应该这样。使用clearAllCachedResultValues();听着,不应该这样。使用clearAllCachedResultValues();看