AddCustomFunctionLibrary
function AddCustomFunctionLibrary(sName: string = null, Func: () = null): void
Description
Register a new custom functions library (see SetCustomFunctions plugin method). The description of the function parameters and result is specified using JSDoc. The @customfunction tag is required in JSDoc. Parameters and results can be specified as the number / string / bool / any / number[][] / string[][] / bool[][] / any[][] types. Parameters can be required or optional. A user can also set a default value.
Parameters
- sName
string
null A name of library
- Func
()
null A custom functions library code.
Returns
void
Try It
Api.AddCustomFunctionLibrary("LibraryName", function(){
/**
* Function that returns the argument
* @customfunction
* @param {any} first First argument.
* @returns {any} second Second argument.
*/
Api.AddCustomFunction(function ADD(first, second) {
return first + second;
});
});
var oWorksheet = Api.GetActiveSheet();
oWorksheet.GetRange('A1').SetValue('=ADD(1,2)');