GridJsのためのカスタム計算エンジンの操作
Contents
[
Hide
]
カスタム計算エンジンの実装
Aspose.Cells.GridJsには、ほとんどのMicrosoft Excel式を計算できる強力な計算エンジンがあります。 このため、デフォルトの計算エンジンを拡張することができ、より大きな力と柔軟性を得ることができます。
この機能の実装に使用される次のプロパティとクラスは次のとおりです。
以下のコードは、カスタム計算エンジンを実装します。 このメソッドは、すべての数式に対して呼び出されるインターフェース GridAbstractCalculationEngine を実装します。 このメソッドでは、MYTESTFUNC の数式を取得し、その第1パラメータの値を2倍にします。
プログラミングサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyCalculation : GridAbstractCalculationEngine | |
{ | |
public override void Calculate(GridCalculationData data) | |
{ | |
if (!"MYTESTFUNC".Equals(data.FunctionName.ToUpper())) | |
{ | |
return; | |
} | |
data.CalculatedValue = (decimal)(2.0 * (double)data.GetParamValue(0)); | |
} | |
} | |
// in the startup.cs when you do initialization ,set the CalculateEngine | |
MyCalculation ce = new MyCalculation(); | |
GridJsWorkbook.CalculateEngine = ce; |