invoke formula in excel via epplus

落爺英雄遲暮 提交于 2019-12-03 23:21:05
ogborstad

Skip the = in the formula string.

Replace currentWorksheet.Cells["C4"].Formula = "=SUM(C2:C3)";

with

currentWorksheet.Cells["C4"].Formula = "SUM(C2:C3)";

As of EpPlus 4.0.1.1, there is an extension method Calculate(this ExcelRangeBase range). Invoke it before accessing Value property:

currentWorksheet.Cells["C4"].Calculate();

and currentWorksheet.Cells["C4"].Value will return the expected value of 40 after that.

I was reviewing my previous answer and found out that the calculation engine of EPPLUS is still in development.

See this discussion on CodePlex. (dating from 2011)

A cite from the roadmap page:

Version 3.2

Formula parser, calc engine

Replacing the Package API with DotNetZip

New cellstore to imporve insert, delete performance and memory consumtion

Last edited Feb 14, 2013

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!