Spread for ASP.NET 8.0 Product Documentation
GetFormula Method (DefaultSheetDataModel)
Example 


Row index of the cell
Column index of the cell
Gets the formula, as a string value, for the cell of the specified row and column.
Syntax
'Declaration
 
Public Function GetFormula( _
   ByVal row As Integer, _
   ByVal column As Integer _
) As String
'Usage
 
Dim instance As DefaultSheetDataModel
Dim row As Integer
Dim column As Integer
Dim value As String
 
value = instance.GetFormula(row, column)
public string GetFormula( 
   int row,
   int column
)

Parameters

row
Row index of the cell
column
Column index of the cell

Return Value

String containing the formula
Remarks
For a list of the operators and functions you can use in formulas, refer to the Spread for .NET Formula Reference.
Example
This example adds data to the first three columns along with formulas to sum the values. The GetFormula method returns the formula from the second column.
Private Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Load

If(Me.IsPostBack)Then Return

FpSpread1.ActiveSheetView.RowCount=10

Dim i As Integer
Dim Str As Object
For i=0 To 3
FpSpread1.ActiveSheetView.SetValue(i,0,i)
FpSpread1.ActiveSheetView.SetValue(i,1,i)
FpSpread1.ActiveSheetView.SetValue(i,2,i)
Next

FpSpread1.ActiveSheetView.Cells(5,0).Formula="SUM(A3:A4)"
FpSpread1.ActiveSheetView.Cells(5,1).Formula="SUM(A3:A4)"
FpSpread1.ActiveSheetView.Cells(5,2).Formula="SUM(A3:A4)"

Dim dm As FarPoint.Web.Spread.Model.DefaultSheetDataModel=CType(FpSpread1.ActiveSheetView.DataModel,FarPoint.Web.Spread.Model.DefaultSheetDataModel)
Str=dm.GetFormula(5,1)
ListBox1.Items.Add(Convert.ToString(Str))
End Sub
private void Page_Load(object sender,System.EventArgs e)
{
if(this.IsPostBack)return;

int i;
object str;
FpSpread1.ActiveSheetView.RowCount=10;
for(i=0;i<=3;i++)
{
FpSpread1.ActiveSheetView.SetValue(i,0,i);
FpSpread1.ActiveSheetView.SetValue(i,1,i);
FpSpread1.ActiveSheetView.SetValue(i,2,i);
}

FpSpread1.ActiveSheetView.Cells[5,0].Formula="SUM(A3:A4)";
FpSpread1.ActiveSheetView.Cells[5,1].Formula="SUM(A3:A4)";
FpSpread1.ActiveSheetView.Cells[5,2].Formula="SUM(A3:A4)";

FarPoint.Web.Spread.Model.DefaultSheetDataModel dm=(FarPoint.Web.Spread.Model.DefaultSheetDataModel)FpSpread1.ActiveSheetView.DataModel;
str=dm.GetFormula(5,1);
ListBox1.Items.Add(Convert.ToString(str));
}
Requirements

Target Platforms: Windows 7, Windows 8, Windows Vista, Windows Server 2000, Windows 2000 Professional, Windows XP Professional, Windows NT 4.0 Workstation, SP6, Windows NT 4.0 Server, SP6

See Also

Reference

DefaultSheetDataModel Class
DefaultSheetDataModel Members
SetFormula Method

 

 


Copyright © GrapeCity, inc. All rights reserved.