Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EPPlus Formula Evaluation

Tags:

c#

excel

epplus

When using EPPlus, I am trying to insert the result of a formula into a cell

ie:

Worksheet.Cells["A4"].Value = 3
Worksheet.Cells["A5"].Value = 4
Worksheet.Cells["A6"].Formula = "=SUM(A3:A4)"
Worksheet.Cells["A6"].Calculate()

In the worksheet i will see the formula in the Formula bar, but what I would like is to evaluate the formula in EPPlus and insert the value into the cell. So when clicking into the cell all i see is 7 and not =SUM(A3:A4)

The reason for this, is because I have large worksheet (for business reasons) and having the formulas calculate when opening means the sheet takes about 20 seconds to load

like image 512
telsokari Avatar asked Jul 20 '26 03:07

telsokari


2 Answers

just to illustrate swmal answer :

epplus calculate

like image 194
Xavave Avatar answered Jul 21 '26 15:07

Xavave


If you want to calculate and remove the actual formula before you send the workbook to the client you should set the Formula property to string.Empty after you have called Calculate(). The calculated value is stored in the Value property of the cell.

like image 42
swmal Avatar answered Jul 21 '26 15:07

swmal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!