Spread for ASP.NET 7.0 Product Documentation
SetFormula Method
See Also  Example Support Options
FarPoint.Web.Spread Assembly > FarPoint.Web.Spread Namespace > SheetView Class : SetFormula Method


row
Row index of the cell
column
Column index of the cell
value
Object that contains the formula for the cell

Glossary Item Box

Sets the formula for a specified 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 SheetView
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
Object that contains the formula for the cell

Remarks

Set this property to a mathematical expression made up of cell references, operators, and functions (either provided or custom functions you define). 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 by using the ReferenceStyle property. The formula cannot contain both absolute and relative row or column references.

The following table contains examples of valid formulas:

Function Description
SUM(A1:A10) Totals the values of rows 1 through 10 in the first column
PI( )*C6 p times the value in cell C6
A# * G# Value in cell in column A, this row, multiplied by the value in cell in column G, this row
(A1 + B1) * C1 Adds the values in the first two cells and multiplies the result by the value in the third cell
IF(A1>5, A1*2, A1*3) If the contents of cell A1 are greater than 5, then multiply the contents of cell A1 by 2, else multiply the contents of cell A1 by 3

Example

This example gets the formula that is set for the specified cell.
C#Copy Code
FarPoint.Web.Spread.SheetView sv;
string s;
sv = FpSpread1.ActiveSheetView;
sv.SetFormula(0, 0, "4*4");
s = sv.GetFormula(0, 0);
Response.Write("The formula for the cell is a " + s);
Visual BasicCopy Code
Dim sv As FarPoint.Web.Spread.SheetView
Dim s As String
sv = FpSpread1.ActiveSheetView
sv.SetFormula(0, 0, "4*4")
s = sv.GetFormula(0, 0)
Response.Write("The formula for the cell is a " & s)

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

© 2002-2014 ComponentOne, a division of GrapeCity. All Rights Reserved.