[]
        
(Showing Draft Content)

C1.WPF.FlexGrid.C1FlexSheet.CalcEngine

CalcEngine Property

CalcEngine

Gets a reference to the FlexGrid calc engine.

Declaration
public ExcelCalcEngine CalcEngine { get; }
Public ReadOnly Property CalcEngine As ExcelCalcEngine
Remarks

The CalcEngine responsible for all calculation jobs underlying the FlexSheet. The major jobs are parsing and evaluating the expressions.

Examples

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;
});