Spread Windows Forms 9.0 Product Documentation
Recalculating and Updating Formulas Automatically

By default, the spreadsheet recalculates formulas in the spreadsheet when the contents of dependent cells change. You can turn this recalculation off. You can also recalculate an individual cell.

Also by default, the spreadsheet updates formulas when you add, insert, or remove columns or rows or when you move or swap blocks of cells. You can turn off these automatic formula updates, but generally you probably want the spreadsheet to update formulas in these cases. Keep in mind how turning off automatic formula updating might impact the spreadsheet if the user moves data, adds rows or columns, or performs other actions that affect the location of data.

When automatic formula updating is on, the spreadsheet updates absolute and relative cell references, as follows:

Use the AutoCalculation property to turn on or off the automatic recalculation of formulas. Use the Recalculate and RecalculateAll methods for recalculating formulas.

Using Code

  1. If needed, set the reference style for the sheet with the ReferenceStyle property.
  2. Add a formula to the cell with the SetFormula method.
  3. Set the RecalculateAll method to recalculate.

Example

This example recalculates all the formulas.

C#
Copy Code
fpSpread1.ActiveSheet.SetValue(0, 0, 20);
fpSpread1.ActiveSheet.SetValue(0, 1, 10);
fpSpread1.ActiveSheet.SetFormula(3, 0, "SUM(A1,B1)");
fpSpread1.ActiveSheet.SetFormula(4, 0, "A1*B1");
fpSpread1.ActiveSheet.SetValue(0, 1, 100);
fpSpread1.ActiveSheet.RecalculateAll();
VB
Copy Code
FpSpread1.ActiveSheet.SetValue(0, 0, 20)
FpSpread1.ActiveSheet.SetValue(0, 1, 10)
FpSpread1.ActiveSheet.SetFormula(3, 0, "SUM(A1,B1)")
FpSpread1.ActiveSheet.SetFormula(4, 0, "A1*B1")
FpSpread1.ActiveSheet.SetValue(0, 1, 100)
FpSpread1.ActiveSheet.RecalculateAll()

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options | Documentation Feedback