New to Telerik Document Processing? Start a free 30-day trial

Abstract base for all spreadsheet functions, defining evaluation logic, argument rules, and metadata for use in formula expressions.

Definition

Namespace:Telerik.Documents.Spreadsheet.Expressions.Functions

Assembly:Telerik.Windows.Documents.Spreadsheet.dll

Syntax:

C#
public abstract class FunctionBase

Inheritance: objectFunctionBase

Derived Classes: ErrorTypeFalseFunctionWithArgumentsIfFunctionIsBlankIsErrIsErrorIsLogicalIsNAIsNonTextIsNumberIsRefIsTextNAPiTodayTrueTypeFunction...

Constructors

Initializes a new function base instance, ready for evaluation in spreadsheet expressions.

C#
protected FunctionBase()

Properties

Specifies how arguments are converted before evaluation, with a default of standard number function conversions including boolean-to-number mapping.

C#
public virtual ArgumentConversionRules ArgumentConversionRules { get; }
Property Value:

The argument conversion rules.

Provides metadata describing the function's category, required and optional arguments, and documentation for help systems.

C#
public abstract FunctionInfo FunctionInfo { get; }
Property Value:

The function info.

When true, FunctionBase automatically evaluates this function element-wise over any multi-element array argument and returns a spilled array result. Override to true in pure scalar functions (e.g. ABS, LEN, MOD) where applying the function independently to each element of an input array is the correct dynamic-array behavior. Leave false (the default) for reducers.

C#
public virtual bool LiftsOverArrays { get; }

Returns the unique function name used in formulas to invoke this function.

C#
public abstract string Name { get; }
Property Value:

The name.

Methods

Evaluates the function using the provided evaluation context and returns the result as an expression. When LiftsOverArrays is true and at least one argument evaluates to a multi-element array, the function is evaluated element-wise over the broadcast dimensions via EvaluateLiftedElement(FunctionEvaluationContext<RadExpression>, RadExpression[], int, int) and a spilled ArrayExpression is returned.

C#
public RadExpression Evaluate(FunctionEvaluationContext<RadExpression> context)
Parameters:contextFunctionEvaluationContext<RadExpression>

The context.

Returns:

RadExpression

Function result as RadExpression.

Evaluates a single element during pointwise array lifting. Called once per cell in the broadcast result. The default implementation passes raw RadExpression arguments to EvaluateOverride(FunctionEvaluationContext<RadExpression>). FunctionWithArguments overrides this to apply argument conversion before calling EvaluateOverride(FunctionEvaluationContext<object>).

C#
protected virtual ConstantExpression EvaluateLiftedElement(FunctionEvaluationContext<RadExpression> context, RadExpression[] resolvedArgs, int row, int col)
Parameters:contextFunctionEvaluationContext<RadExpression>

The original evaluation context (for worksheet, row/col, function expression).

resolvedArgsRadExpression[]

All arguments resolved to constants (arrays preserved).

rowint

The current row in the broadcast result.

colint

The current column in the broadcast result.

Returns:

ConstantExpression

The result for this cell, or an error expression.

Performs the function-specific evaluation logic; override in derived classes to implement custom calculation behavior.

C#
protected virtual RadExpression EvaluateOverride(FunctionEvaluationContext<RadExpression> context)
Parameters:contextFunctionEvaluationContext<RadExpression>

The context.

Returns:

RadExpression

Function result as RadExpression.

Validates that the argument count falls within the acceptable range for this function, accounting for required and optional parameters and repetition rules.

C#
public bool IsArgumentNumberValid(int argumentsCount)
Parameters:argumentsCountint

The arguments count.

Returns:

bool

Boolean indicating whether the arguments number is valid.

Determines whether the argument at argumentIndex can cause this function to return a multi-element array (and therefore to spill). The default implementation combines the argument metadata with the argument expression's array-return capability. Override when spilling depends on the argument's runtime value.

C#
public virtual bool IsSpillingArgument(int argumentIndex, RadExpression argument)
Parameters:argumentIndexintargumentRadExpressionReturns:

bool