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
Namespace: FlexCel.Core
public abstract Object Evaluate(TUdfEventArgs arguments, Object[] parameters)
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
arguments | TUdfEventArgs | Extra objects you can use to evaluate the function. | |
parameters | Object[] | 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 one of the following objects: * Null. (Nothing in VB). If the parameter is empty or missing. * A "System.Boolean" * A "System.String" * A "System.Double" * A TXls3DRange This will be returned when the argument is a cell reference. * A TFlxFormulaErrorValue. Except in very special cases (like an IsError function), the expected behavior in Excel is that whenever you get an Error parameter your function should return the same error and exit. You can use the method CheckParameters to implement that. * A 2-dimensional array of objects, where each object in the array will be of any of the types mentioned here again. 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 of objects (object?[,]) 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.