FlexSheet for WPF | ComponentOne
C1.WPF.FlexGrid Namespace / C1FlexSheet Class / CalcEngine Property
Example

In This Topic
    CalcEngine Property
    In This Topic
    Gets a reference to the FlexGrid calc engine.
    Syntax
    'Declaration
     
    
    Public ReadOnly Property CalcEngine As ExcelCalcEngine
    public ExcelCalcEngine CalcEngine {get;}
    Remarks
    The CalcEngine responsible for all calculation jobs underlying the FlexSheet. The major jobs are parsing and evaluating the expressions.
    Example
    This sample showing how to register a custom function to the CalcEngine.
    flexSheet.CalcEngine.RegisterFunction("GREATEST", 1, (expressions) =>
    {
        CellRangeReference rangeReference = (expressions[0] as XObjectExpression).Value as CellRangeReference;
        if (rangeReference != null)
        {
            var enumerator = rangeReference.GetEnumerator();
            double greatest = double.MinValue;
            while (enumerator.MoveNext())
            {
                double? v = (enumerator.Current as double?);
                if (v.HasValue)
                    greatest = Math.Max(greatest, v.Value);
            }
            return greatest;
        }
        return null;
    });
    See Also