Spread ASP.NET 6.0 Product Documentation
SetFormula Method
See Also  Example Send Feedback
FarPoint.Web.Spread Assembly > FarPoint.Web.Spread.Model Namespace > DefaultSheetDataModel Class : SetFormula Method


row
Row index of the cell
column
Column index of the cell
value
Formula to be set, as a string

Glossary Item Box

Sets the formula, as a string value, for the cell of the specified row and column. If you pass null, it will clear the expression from that cell.

Syntax

Visual Basic (Declaration) 
Public Sub SetFormula( _
   ByVal row As Integer, _
   ByVal column As Integer, _
   ByVal value As String _
) 
Visual Basic (Usage)Copy Code
Dim instance As DefaultSheetDataModel
Dim row As Integer
Dim column As Integer
Dim value As String
 
instance.SetFormula(row, column, value)
C# 
public void SetFormula( 
   int row,
   int column,
   string value
)

Parameters

row
Row index of the cell
column
Column index of the cell
value
Formula to be set, as a string

Exceptions

ExceptionDescription
ParseException Specified value is not a valid formula

Remarks

For a list of the operators and functions you can use in formulas, refer to the Spread for .NET Formula Reference.

The Spread component can use absolute or relative cell references. You define the cell reference style for the spreadsheet The formula cannot contain both absolute and relative row or column references.

Example

This example creates a new DefaultSheetDataModel, sets its number of rows and columns in the constructor and attaches it to the DataModel of the active sheet. Data is added to the first three columns along with formulas to sum the values.
Visual BasicCopy Code
PrivateSubPage_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Load

If(Me.IsPostBack)ThenReturn

DimdmAsNewFarPoint.Web.Spread.Model.DefaultSheetDataModel(8,8)
FpSpread1.ActiveSheetView.DataModel=dm

DimiAsInteger
Fori=0To3
FpSpread1.ActiveSheetView.SetValue(i,0,i)
FpSpread1.ActiveSheetView.SetValue(i,1,i)
FpSpread1.ActiveSheetView.SetValue(i,2,i)
Next
dm.SetFormula(5,0,"SUM(A3:A4)")
dm.SetFormula(5,1,"SUM(B1:B2)")
dm.SetFormula(5,2,"SUM(C1:C3)")

ListBox1.Items.Add(dm.GetFormula(5,0).ToString())
ListBox1.Items.Add(dm.MaximumIterations.ToString())
ListBox1.Items.Add(dm.ReferenceStyle.ToString())

EndSub
C#Copy Code
privatevoidPage_Load(objectsender,System.EventArgse)
{
if(this.IsPostBack)return;

FarPoint.Web.Spread.Model.DefaultSheetDataModeldm=newFarPoint.Web.Spread.Model.DefaultSheetDataModel(10,10);
FpSpread1.ActiveSheetView.DataModel=dm;

inti;
for(i=0;i<=3;i++)
{
FpSpread1.ActiveSheetView.SetValue(i,0,i);
FpSpread1.ActiveSheetView.SetValue(i,1,i);
FpSpread1.ActiveSheetView.SetValue(i,2,i);
}
dm.SetFormula(5,0,"SUM(A3:A4)");
dm.SetFormula(5,1,"SUM(B2:B4)");
dm.SetFormula(5,2,"SUM(C1:C3)");

ListBox1.Items.Add(dm.GetFormula(5,0).ToString());
ListBox1.Items.Add(dm.MaximumIterations.ToString());
ListBox1.Items.Add(dm.ReferenceStyle.ToString());
}

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2002-2012 GrapeCity, Inc. All Rights Reserved.