Excel计算问题
我有 .xlsx 文档,其中需要将一些值导入到具有已定义名称的单元格中。这些单元格很少被格式化为货币,并且我在这些单元格中导入的值是小数类型,我以这种方式导入:
cell.CellValue = new CellValue(value.ToString().Replace(",", "."));
在同一个电子表格中,有一些单元格具有一个公式,其中使用我导入的货币单元格(例如,我在定义名称 Total
的单元格 H27
中导入值,并且在字段 I27
中有公式 =Total*0.23
)。
导入完成后,值已成功导入(并正确格式化为货币),但公式单元格无法正确计算,直到我单击每个公式单元格的公式复选标记或更改货币值(在这种情况下,所有包含该单元格已刷新)。
导入完成后,带有公式的单元格要如何自动计算值,我需要做什么?
I have .xlsx document in which I need to import some values to cells with defined names. Few of those cells are formatted as currency and values that I am importing in those cells are of decimal
type which I import in this manner:
cell.CellValue = new CellValue(value.ToString().Replace(",", "."));
In the same spreadsheet there are a few cells that have a formula in which currency cells I imported are used (eg., I am importing value in cell H27
with defined name Total
, and in the field I27
there is a formula =Total*0.23
).
After import is complete, values are successfully imported (and correctly formatted as currency), but formula cells are not correctly calculated until I either click on formula check marks for each formula cell or I change the currency value (in this case, all formulas containing this cell are refreshed).
What do I have to do for cells with formulas to automatically calculate values after import is completed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经弄清楚了。带有公式的单元格内部有
字段。这些字段具有bool
属性CalculateCell
,如果设置为 true,则告诉 Excel 在打开文件后计算公式。由于我事先不知道哪些公式单元格受到单元格的影响,因此我像这样管理所有单元格:I've figured it out. The cells with formula have
<CellFormula>
fields inside of them. Those fields havebool
attributeCalculateCell
which, if set to true, tells Excel to calculate the formula after opening the file. Since I don't know up front which formula cells are affected by the cells, I manage all of them like this: