Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a custom function in a functionRegistry #146

Open
dmziryanov opened this issue Mar 5, 2021 · 5 comments
Open

How to create a custom function in a functionRegistry #146

dmziryanov opened this issue Mar 5, 2021 · 5 comments

Comments

@dmziryanov
Copy link

How to create a custom simple function, for a example foo() to insert in a cell '=foo()'?
Is it possible without modification the source code?

@ShockwaveNN
Copy link
Contributor

@askonev Please take a look

@askonev
Copy link
Member

askonev commented Mar 5, 2021

Hello, @dmziryanov
Perhaps the use of our macros will help you to solve your problem.
Example. Let's find with the help of macros the minimum value from the range of cells from B1 to B3.

Screen record from 2021-03-05 11 20 43

Script

(function()
{
    oWorksheet = Api.GetActiveSheet();
    oWorksheet.GetRange("A1").SetValue("=min(B1:B3)");
})();

@dmziryanov
Copy link
Author

dmziryanov commented Mar 5, 2021

Plugins and macroses are great to help, but the best way to solve our problem is to push a custom function (e.g. foo(A2, B2)) through the table and fill certain cells.

This function is impossible to create like combination of the existing functions because it should take data from REST API with token authorization and should be defined in such way that cell analizer could evaluate it like other functions (like MS Excel could evaluate custom function with custom calculations defined in macros).

As far as I could understood this is imposible without modification ONLYOFFICE/core

@askonev
Copy link
Member

askonev commented Mar 5, 2021

@dmziryanov Yes, you're right about the fact that adding such functionality will require a modification ONLYOFFICE/core. However, how do you look at the analog of the LAMBDA functions. At the moment we do not have this functionality, but we will think about its implementation.

@kayanme
Copy link

kayanme commented Mar 9, 2021

I can suggest more straightforward case to discuss. We have a need to call a REST web-service and then store the result in the target cell. Is there a way to make such an operation except the macro above (i.e. SetValue...)?
F.e. some built-in function for an external service call?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants