using IronXL;
WorkBook workbook = WorkBook.Load("test.xlsx");
WorkSheet worksheet = workbook.DefaultWorkSheet;
// Set Formulas
worksheet["A1"].Formula = "Sum(B8:C12)";
worksheet["B8"].Formula = "=C9/C11";
worksheet["G30"].Formula = "Max(C3:C7)";
// Force recalculate all formula values in all sheets.
workbook.EvaluateAll();
// Get Formulas
// Get the formula's calculated value. e.g. "52"
string formulaValue = worksheet["G30"].Value;
//Get the formula as a string. e.g. "Max(C3:C7)"
string formulaString = worksheet["G30"].Formula;
//Save your changes with updated formulas and calculated values.
workbook.Save();
Imports IronXL
Private workbook As WorkBook = WorkBook.Load("test.xlsx")
Private worksheet As WorkSheet = workbook.DefaultWorkSheet
' Set Formulas
Private worksheet("A1").Formula = "Sum(B8:C12)"
Private worksheet("B8").Formula = "=C9/C11"
Private worksheet("G30").Formula = "Max(C3:C7)"
' Force recalculate all formula values in all sheets.
workbook.EvaluateAll()
' Get Formulas
' Get the formula's calculated value. e.g. "52"
Dim formulaValue As String = worksheet("G30").Value
'Get the formula as a string. e.g. "Max(C3:C7)"
Dim formulaString As String = worksheet("G30").Formula
'Save your changes with updated formulas and calculated values.
workbook.Save()