SPREAD for WPF 4.0J - GcSpreadGrid
GetFormula メソッド
使用例 

GrapeCity.Windows.SpreadGrid 名前空間 > GcSpreadGrid クラス : GetFormula メソッド
行インデックス。
列インデックス。
カルチャ。
参照スタイル。
GcSpreadGrid 内の指定したセルの数式を取得します。
シンタックス
'宣言
 
Public Function GetFormula( _
   ByVal row As Integer, _
   ByVal column As Integer, _
   Optional ByVal culture As CultureInfo, _
   Optional ByVal referenceStyle As Nullable(Of ReferenceStyle) _
) As String

パラメータ

row
行インデックス。
column
列インデックス。
culture
カルチャ。
referenceStyle
参照スタイル。

戻り値の型

数式文字列を返します。
使用例
次のサンプルはGetFormulaメソッドの使用方法を説明します。
public void Formula4()
{
    GcSpreadGrid gcSpread1 = new GcSpreadGrid();
    gcSpread1.CanUserEditFormula = true; // Allow the users edit formula by UI (user interface).
    gcSpread1.Columns[0].Name = "column1";
    gcSpread1[0, 0].Value = 1;
    gcSpread1[0, 1].Value = 2;
    gcSpread1[1, 0].Value = 3;
    gcSpread1[1, 1].Value = 4;

    gcSpread1[0, 2].Formula = "SUM(A1:B2)";
    gcSpread1[1, 2].Formula = "SUM(column1)"; // You can use the column name on formula.
    object result = gcSpread1[0, 2].Value; // The value of result is 10.
    result = gcSpread1[1, 2].Value; // The value of result is 4.
    string formula = gcSpread1.GetFormula(0, 2); // the value of formula is "SUM(A1:B2)";
    gcSpread1.SetFormula(0, 2, "AVERAGE(A1:B2)");
    result = gcSpread1[0, 2].Value; // The value of result is 2.5.

    CalcExpression expression = gcSpread1.GetExpression(0, 2) as CalcExpression;
    expression = new CalcBinaryOperatorExpression(CalcBinaryOperators.Add, expression, new CalcDoubleExpression(10));
    gcSpread1.SetExpression(0, 2, expression);
    result = gcSpread1[0, 2].Value;// The value of result is 12.5.
    formula = gcSpread1.GetFormula(0, 2);// the value of formula is "AVERAGE(A1:A2)+10";
}
Public Sub Formula4()
    Dim gcSpread1 As New GcSpreadGrid()
    gcSpread1.CanUserEditFormula = True
    ' Allow the users edit formula by UI (user interface).
    gcSpread1.Columns(0).Name = "column1"
    gcSpread1(0, 0).Value = 1
    gcSpread1(0, 1).Value = 2
    gcSpread1(1, 0).Value = 3
    gcSpread1(1, 1).Value = 4

    gcSpread1(0, 2).Formula = "SUM(A1:B2)"
    gcSpread1(1, 2).Formula = "SUM(column1)"
    ' You can use the column name on formula.
    Dim result As Object = gcSpread1(0, 2).Value
    ' The value of result is 10.
    result = gcSpread1(1, 2).Value
    ' The value of result is 4.
    Dim formula As String = gcSpread1.GetFormula(0, 2)
    ' the value of formula is "SUM(A1:B2)";
    gcSpread1.SetFormula(0, 2, "AVERAGE(A1:B2)")
    result = gcSpread1(0, 2).Value
    ' The value of result is 2.5.
    Dim expression As CalcExpression = TryCast(gcSpread1.GetExpression(0, 2), CalcExpression)
    expression = New CalcBinaryOperatorExpression(CalcBinaryOperators.Add, expression, New CalcDoubleExpression(10))
    gcSpread1.SetExpression(0, 2, expression)
    result = gcSpread1(0, 2).Value
    ' The value of result is 12.5.
    formula = gcSpread1.GetFormula(0, 2)
    ' the value of formula is "AVERAGE(A1:A2)+10";
End Sub
参照

GcSpreadGrid クラス
GcSpreadGrid メンバ