AbstractCalculationEngine Class
Represents user's custom calculation engine to extend the default calculation engine of Aspose.Cells.
Inheritance Hierarchy
SystemObject
  Aspose.CellsAbstractCalculationEngine

Namespace: Aspose.Cells
Assembly: Aspose.Cells (in Aspose.Cells.dll) Version: 19.9.0.0 (19.9)
Syntax
public abstract class AbstractCalculationEngine

The AbstractCalculationEngine type exposes the following members.

Constructors
  NameDescription
Protected methodAbstractCalculationEngine
Initializes a new instance of the AbstractCalculationEngine class
Properties
  NameDescription
Public propertyIsParamLiteralRequired
Indicates whether this engine needs the literal text of parameter while doing calculation. Default value is false.
Methods
  NameDescription
Public methodCalculate
Calculates one function with given data.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Remarks
User should not modify any part of the Workbook directly in this implementation(except the calculated result of the custom function, which can be set by CalculationData.CalculatedValue property). Otherwise unexpected result or Exception may be caused. If user needs to change other data than calculated result in the implementation for some custom functions, for example, change cell's formula, style, ...etc., user should gather those data in this implementation and change them out of the scope of formula calculation.
Examples
[C#]
public class MyEngine : AbstractCalculationEngine
{
    public override void Calculate(CalculationData data)
    {
        string funcName = data.FunctionName.ToUpper();
        if ("MYFUNC".Equals(funcName))
        {
            //do calculation for MYFUNC here
            int count = data.ParamCount;
            object res = null;
            for (int i = 0; i < count; i++)
            {
                object pv = data.GetParamValue(i);
                if (pv is ReferredArea)
                {
                    ReferredArea ra = (ReferredArea)pv;
                    pv = ra.GetValue(0, 0);
                }
                //process the parameter here
                //res = ...;
            }
            data.CalculatedValue = res;
        }
    }
}
See Also