добавление новой формулы
| name | string | название формулы (буквами в верхнем регистре) |
| handler | function | обработчик, который определяет логику работы формулы |
| category | string | optional, the name of a custom category for a new math method |
| generateHTML | boolean | optional, allows a custom method to generate HTML, while the xssSafe property is enabled |
$$("ss1").registerMathMethod("NEW", function(value){
// ваш обработчик
});
Функция-обработчик может получать параметры, например значение одной ячейки, значения из диапазона ячеек (значения будут передаваться по ссылкам, например H3 или H3:H5) или произвольные параметры (например, число знаков после запятой, до которого нужно округлить число).
Новую формулу можно использовать как обычную встроенную функцию: =NEW(H3:H5);.
Вы можете добавить подсказки для параметров новой формулы, обновив локаль webix.i18n.spreadsheet.liveEditor["functions-syntax"].

Например:
const ssheet = webix.ui({
view: "spreadsheet",
toolbar: "full"
});
ssheet.registerMathMethod("RANDOM", function(value){ value = value || 100; return Math.round(Math.random()*value); });
webix.i18n.spreadsheet.liveEditor["functions-syntax"].RANDOM = [ ["Digit", "Optional. The number digit."] ];
ssheet.setCellValue(1,1,"=RANDOM(100)")
It is also possible to specify a custom category while adding a new math method:
webix.ui({
view:"spreadsheet",
id: "sheets",
methods:"all",
toolbar:"full",
});
webix.i18n.spreadsheet.liveEditor.custom = "Custom";
$$("sheets").registerMathMethod("returnone", () => 1, "custom");
$$("sheets").setCellValue(1, 1, "=RETURNONE()")

If you need to allow a custom method to generate HTML, while the xssSafe property is enabled, set the generateHTML parameter of the registerMathMethod() method to true. Check the example below:
const spreadsheet = webix.ui({
view: "spreadsheet",
xssSafe: true
});
spreadsheet.registerMathMethod("bold", v => `<b>${v}</b>`, null, true);
spreadsheet.setCellValue(1, 1, '=bold("text")');
Note that while using the method with allowed HTML generation in math formulas, you should specify only the method in the formula. For example: =IMAGE(...) will generate an image, but =IMAGE(...)&"text" will be escaped.