protected void btnAddFormula_Click(object sender, EventArgs e)
{
// Clear GridWeb and add a new worksheet
GridWeb1.WorkSheets.Clear();
GridWeb1.WorkSheets.Add();
// ExStart:AddFormulas
// Accessing the worksheet of the Grid that is currently active
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
// Putting some values to cells
sheet.Cells["A1"].PutValue("1st Value");
sheet.Cells["A2"].PutValue("2nd Value");
sheet.Cells["A3"].PutValue("Sum");
sheet.Cells["B1"].PutValue(125.56);
sheet.Cells["B2"].PutValue(23.93);
// Adding a simple formula to "B3" cell
sheet.Cells["B3"].Formula = "=SUM(B1:B2)";
// ExEnd:AddFormulas
// ExStart:CalculateFormulas
// Calculating all formulas added in worksheets
GridWeb1.WorkSheets.CalculateFormula();
// ExEnd:CalculateFormulas
}