user6283344
user6283344

Reputation:

Evaluating formula from csv using EPPlus

To load formulas in a range I've used this method

ws1.Cells["B4:D4"].LoadFromText($"={con_Fu_LF},={con_Un_LF},={con_Fo_LF}");

and to evaluate I've called

ws1.Cells["B4:D4"].Calculate();

Opening the workbook I see strings in that range, for example in B4:

='Fu-LF'!F6841+'Fu-LF'!K6841

these are evaluated when I click on formula bar selecting a cell and press enter.

I want these to be evaluated automatically, how to do?

Upvotes: 2

Views: 316

Answers (1)

Ernie S
Ernie S

Reputation: 14250

LoadFromText sets the cell .Value property. But you need to set the .Formula like this:

ws.Cells["B4"].Formula = $"={con_Fu_LF}";

It works with the spacebar trick because that is Excel itself detecting that it "looks" like a formula and automatically setting it.

There is no way to do it that doesnt require you to loop through the cells/strings manually.

Upvotes: 0

Related Questions