Cell.value or cell.putvalue breaks formula

Problem: I have an Excel workbook for equipment testing. I populate the cells with a value:

Cell c11 = ws.Cells[“C11”];
c11.Value = readingList1[0];

Cell c19 = ws.Cells[“C19”];
c19.PutValue(readingList2[0]);

The problem is when I open up the workbook it acts as if there is no number there. In the screen shot I have highlighted cell D11. It acts as if the value is not in cell C11 which I populate with the code above. But if I manual put in a value like I did with C12 the formula works. Am I missing something here??? or is there a way to populate the cells and have the formulas work? I have tried both Cell.Value = something and Cell.PutValue(something) and it behaves the same.

Screenshot (11).png (34.2 KB)

@morbeck,

Thanks for the screenshot and details.

Could you please call Workbook.CalculateFormula() method before saving the Excel file? If you still encounter the issue, kindly provide your template Excel file (please zip the file before attaching), and we will investigate it promptly.

Thanks amjad… that did the trick… Wasn’t aware I needed to call that function first…

@morbeck,

That is great. Whenever you update values in the source cells and you don’t want MS Excel to calculate/recalculate when opening the output Excel file, you can use the Workbook.CalculateFormula method to always get updated values in the formula cells.