[]
Spread.CalcEngine.Functions
▸ 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());
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the function. |
fn |
Function |
The function to add. |
The function that was added.
▸ findGlobalFunction(name?): any
Gets all of the global functions or one global function that specified by name.
| Name | Type | Description |
|---|---|---|
name? |
string |
The name of the function. |
any
If the name is empty, return all of the global functions, otherwise, return one function with the specified name.
▸ removeGlobalFunction(name?): void
If the name is empty, remove all of the global functions, otherwise, remove one function with the specified name.
| Name | Type | Description |
|---|---|---|
name? |
string |
The name of the function. |
void