Spread Windows Forms 9.0 Product Documentation
Formula Property (Cell)
Example 


Gets or sets the formula in a cell.
Syntax
'Declaration
 
Public Property Formula As String
'Usage
 
Dim instance As Cell
Dim value As String
 
instance.Formula = value
 
value = instance.Formula
public string Formula {get; set;}

Property Value

String containing formula
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 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.

Returning the value of the Formula property provides a string containing the written expression of the formula, for example, SUM(A1:B1). However, if you have changed the cell reference style to a style that cannot represent the formula, the Spread component provides the formula with question marks as placeholders for cell references that cannot be represented.

For more information about formulas, refer to the Formula Reference.

Example
This example creates a Cell object and uses its formula property to sum the values of two cells.
using FarPoint.Win.Spread;
using FarPoint.Win;

private void Form1_Load(object sender, System.EventArgs e)
{
     Cell acell, mycell, urcell;
     acell = fpSpread1.ActiveSheet.Cells[0, 0];
     mycell = fpSpread1.ActiveSheet.Cells[2, 2];
     urcell = fpSpread1.ActiveSheet.Cells[2, 3];
     mycell.Value = 10;
     urcell.Value = 10;
     acell.Formula = "SUM(" + mycell.ToString() + "," + urcell.ToString() + ")";    
}
Imports FarPoint.Win.Spread
Imports FarPoint.Win

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     Dim acell, mycell, urcell As FarPoint.Win.Spread.Cell
     acell = FpSpread1.ActiveSheet.Cells(0, 0)
     mycell = FpSpread1.ActiveSheet.Cells(2, 2)
     urcell = FpSpread1.ActiveSheet.Cells(2, 3)
     mycell.Value = 10
     urcell.Value = 10
     acell.Formula = "SUM(" + mycell.ToString() + "," + urcell.ToString() + ")"
End Sub
Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows Server 2012 R2, Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10

See Also

Reference

Cell Class
Cell Members

 

 


Copyright © GrapeCity, inc. All rights reserved.