chris vietor
chris vietor

Reputation: 2060

Excel formular not refreshing after programmatically changing data with OpenXML

i have the following scenario.

Cells in Col A and Col B get user entered values (A,B,C or D). If both Cells have Values, the formular in Col C calculated a value ( A & A = 1, C & D = 3, and so on).

exactly the same happens in Col R, S and T

now if i execute my c# code, open the spreadsheet with openxml and manipulate the data (cut values in R and S and paste them in A and B), the formular in C does not refresh.

if i press ctrl + alt + F9, the formular updates. But i cannot explain my customer to update his formulars manually every time :)

any hints on forcing the spreadsheet to recalculate that formular?

Upvotes: 1

Views: 600

Answers (1)

chris vietor
chris vietor

Reputation: 2060

myCell.CellFormula.CalculateCell = true;

i tried that before, but i a if statement, where i checked if myCell.DataType !=null in that case, DataType was null, so that line was not executed.

So, CalculateCell solved the problem.

Upvotes: 1

Related Questions