公式在Excel中不考虑细胞中动态生成的值 [英] Formula in excel not considering dynamically generated values in cells

查看:215
本文介绍了公式在Excel中不考虑细胞中动态生成的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些细胞,是基于其他单元格值的公式(比如A1,B1),这反过来都可以从database.My公式填充即将到来正确的,但它总是考虑A1空值, B1 ...即,在打开我的excel,价值在有公式的单元格总是zero..un​​less我改变它在生成Excel中。

I'm having a formula in some cells which is based on values in other cells(say A1,B1) which in turn are getting populated from database.My formula is coming correct but it is always considering null value in A1,B1...ie,on opening my excel, the value in cells having formula is always zero..unless I change it in the generated excel.

我想它考虑哪些越来越动态填充单元格的值,然后显示result.Please帮助!!!!!

I want it to consider cell values which are getting dynamically populated and then show the result.Please help!!!!!

推荐答案

在情况下,你的表有一些公式比如说 A3 = SUM(A1:A2)计算和这是工作的罚款与A1 = 5,A2 = 4。现在,如果改变A2与2值如

In case your sheet has some formula for say A3=sum(A1:A2) is calculated and it is working fine with A1=5, A2 =4. Now if change the value of A2 with 2 like

sh.getRow(0).getCell(0).setCellValue(2);  // set A1=2 

和执行写操作,检查它仍呈现9. A3的价值似乎错了,但不actully。 的一点是,Excel的缓存previously计算结果和需要触发重新计算更新它们。

and perform write operation, check the value of A3 it is still showing 9. It seems wrong but actully not. The point is that Excel caches previously calculated results and you need to trigger recalculation to updated them.

wb.getCreationHelper().createFormulaEvaluator().evaluateAll();

 wb.setForceFormulaRecalculation(true);

然后再执行写操作。这会给你正确的结果。查看详细检查这里

这篇关于公式在Excel中不考虑细胞中动态生成的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆