Posted 14 November 2023, 3:19 pm EST - Updated 14 November 2023, 3:24 pm EST
When creating custom functions, we’d like to include descriptions of the function parameters. For example, with the FACTORIAL example function, we have code (Vue3) such as:
customFormulas() {
// allow dynamic array
this.spread.options.allowDynamicArray = true;
// create a factorial function
function FactorialFunction() {
this.name = 'FACTORIAL';
this.maxArgs = 1;
this.minArgs = 1;
}
FactorialFunction.prototype = new GC.Spread.CalcEngine.Functions.Function();
//evaluating the result of the formula
FactorialFunction.prototype.evaluate = function (arg) {
var result = 1;
if (arguments.length === 1 && !isNaN(parseInt(arg))) {
for (var i = 1; i <= arg; i++) {
result = i * result;
}
return result;
}
return '#VALUE!';
};
//Adding a description to the custom Function
FactorialFunction.prototype.description = function () {
return {
name: 'FACTORIAL',
description: 'This is function which calculates the factorial from 1 and show in different cells of a row'
};
};
var factorial = new FactorialFunction();
this.spread.addCustomFunction(factorial);
}
How can we set the parameter description to ‘number’ for example, to show in the formula popup?