TX Sheet Control

CustomFunctionDefinition.evaluate Method

Method

The evaluate operation of CustomFunctionDefinition.

Owner: CustomFunctionDefinition. Package: @txtextcontrol/tx-sheet-control-server. Version: 2.0.0.

Syntax

evaluate(arguments_: readonly FunctionValue[], context: CustomFunctionContext): FunctionValue | Promise<FunctionValue>

Parameters

ParameterTypeOptionalDescription
arguments_readonly FunctionValue[]NoValue matching arguments_'s declared type and the owning object's validation rules.
contextCustomFunctionContextNoValue matching context's declared type and the owning object's validation rules.

Return Value

FunctionValue | Promise<FunctionValue>.

Examples

Pass an existing CustomFunctionDefinition from the owning document. Related handles and input bytes must belong to the intended document and application; the function applies the operation and inspects its result.

import type { ServerSheetControl } from '@txtextcontrol/tx-sheet-control-server';

function applyCustomFunctionDefinitionEvaluate(
    customFunctionDefinition: Parameters<ServerSheetControl['workbook']['calculation']['registerFunction']>[1],
) {
    const result = customFunctionDefinition['evaluate']([], {
        sheetId: 'sales-sheet',
        address: 'B8',
        signal: {
            aborted: false,
            addEventListener: (type, listener) => {
                console.log(type);
            },
            removeEventListener: (type, listener) => {
                console.log(type);
            },
            throwIfAborted: () => {
                console.log('Operation completed');
            },
        },
    });

    console.log(result);
}

Remarks

Use this member on an object from the current document. Reacquire document-bound handles after replacement/deletion. Validate arguments against the declared types and documented bounds; handle exceptions or rejected promises.

See Also