Search Results for

    Show / Hide Table of Contents

    TUserDefinedFunction.Evaluate Method

    Override this method to provide your own implementation on the function.

    If this method throws an exception, it will not be handled and the recalculation will be aborted. So if you want to return an error, return a TFlxFormulaErrorValue value.

    Do not use any global variable in this method, it must be stateless and always return the same value when called with the same arguments.

    See 'Using excels user defined functions udf' in the Api Developer Guide for more information.

    Syntax

    Unit: FlexCel.Core

    function TUserDefinedFunction.Evaluate(const arguments: TUdfEventArgs; const parameters: TArray<TFormulaValue>): TFormulaValue; virtual; abstract;

    Parameters

    <-> Parameter Type Description
    const arguments TUdfEventArgs Extra objects you can use to evaluate the function.
    const parameters TArray<​TFormula​Value> Parameters for the function. When this method is called by FlexCel, this parameter will never be null, but might be an array of zero length if there are no parameters.

    Each parameter in the array will always be a TFormulaValue
    This class provides utility methods like TryGetDouble that will help you get a specific type of object from a parameter.

    Returns

    Return any object you want here. Normally a double, a string, a boolean a TFlxFormulaErrorValue or a null. If this method returns a class, it will be converted to an allowed value, normally to a string. If you want to return an array for an array formula, return a 2-dimensional array in the result, where the elements of the array are the values you want to return.

    Examples

    See 'Using excels user defined functions udf' in the Api Developer Guide for examples.

    See also

    • TUserDefinedFunction
    In This Article
    Back to top FlexCel Studio for VCL and FireMonkey v7.24
    © 2002 - 2025 tmssoftware.com