GrapeCity SPREAD for WPF 2.0J
GetExpression メソッド

行インデックス。
列インデックス。
GcSpreadGrid 内の指定したセルの式を取得します。
構文
'Declaration
 
Public Function GetExpression( _
   ByVal row As Integer, _
   ByVal column As Integer _
) As GrapeCity.CalcEngine.Expressions.CalcExpression
public GrapeCity.CalcEngine.Expressions.CalcExpression GetExpression( 
   int row,
   int column
)

パラメータ

row
行インデックス。
column
列インデックス。

戻り値の型

GrapeCity.CalcEngine.Expressions.CalcExpression オブジェクトを返します。
次のサンプルはGetExpressionメソッドの使用方法を説明します。
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 メンバ

 

 


Copyright © 2012 GrapeCity inc. All rights reserved.