ONLYOFFICE-QA / doc-builder-testing

GNU Affero General Public License v3.0
1 stars 11 forks source link

[8.1] AddCustomFunction #1238

Open askonev opened 1 week ago

askonev commented 1 week ago

https://api.onlyoffice.com/officeapi/spreadsheetapi/api/addcustomfunction https://api.onlyoffice.com/officeapi/spreadsheetapi/api/clearcustomfunctions https://api.onlyoffice.com/officeapi/spreadsheetapi/api/removecustomfunction

builder.CreateFile("xlsx");
/**
* Calculates the sum of the specified numbers.
* @customfunction
* @nameLocale {ru: Добавить | fr:Ajouter | es:Añadir}
* @param {number} first The first number
* @param {number} [second] The second number
* @returns {number} The sum of the numbers.
*/
Api.AddCustomFunction(function ADD(first, second) {
    if (second === null) {
        second = 0;
    }
   return first + second;
});

var oWorksheet = Api.GetActiveSheet();
oWorksheet.GetRange('A1').SetValue('=ADD(1,2)');
builder.SaveFile("xlsx", "AddCustomFunction.xlsx");
builder.CloseFile();