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

sNamestringdefault: null

A name of library

Func()default: 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)');

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).