[]
        
(Showing Draft Content)

GC.Spread.CalcEngine.Functions

Namespace: Functions

Spread.CalcEngine.Functions

Table of contents

Enumerations

Classes

Interfaces

Functions

Functions

defineGlobalCustomFunction

defineGlobalCustomFunction(name, fn): Function

Defines a global custom function, which can be used in formulas. The global custom function can be called from any spreadsheet.

example

class FactorialFunction extends GC.Spread.CalcEngine.Functions.Function {
    constructor () {
        super('FACTORIAL', 1, 1, {
            description: "Function to calculate the Fibonacci number.",
            parameters: [{ name: 'n' }]
        });
    }
    evaluate (n) {
        var fib = [0, 1];
        for (var i = 2; i <= n; i++) {
          fib[i] = fib[i - 1] + fib[i - 2];
        }
        return fib[n];
    }
}
GC.Spread.CalcEngine.Functions.defineGlobalCustomFunction("FACTORIAL", new FactorialFunction());

Parameters

Name Type Description
name string The name of the function.
fn Function The function to add.

Returns

Function

The function that was added.


findGlobalFunction

findGlobalFunction(name?): any

Gets all of the global functions or one global function that specified by name.

Parameters

Name Type Description
name? string The name of the function.

Returns

any

If the name is empty, return all of the global functions, otherwise, return one function with the specified name.


removeGlobalFunction

removeGlobalFunction(name?): void

If the name is empty, remove all of the global functions, otherwise, remove one function with the specified name.

Parameters

Name Type Description
name? string The name of the function.

Returns

void