Hi,
I am using HyberFormulas. In this, I am trying to do some calculations using custom functions.
I want to pass arguments (another cell value) in custom functions to perform calculations. Is there any way to achieve this?
Ex: =calculate("=A1") + 3
Hi,
I am using HyberFormulas. In this, I am trying to do some calculations using custom functions.
I want to pass arguments (another cell value) in custom functions to perform calculations. Is there any way to achieve this?
Ex: =calculate("=A1") + 3
Here’s a tutorial about how to create custom functions with HyperFormula:
https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-custom-function
if i pass any value directly to custom function, i can get that value in “ast.args”. so i can proceed further. But I am passing argument as a named expression in custom functions. i am not able to get the value of named expression in “ast.args”.
Could you help on this scenario. Handsontable example - JSFiddle - Code Playground
I have consulted this with my colleague and it turned out that this is the issue reported here:
I will get back to you next week with more information on this.
Sure. thank you @adrian.szymanski
I just received more information on this issue.
This is a custom function that accepts a parameter. It’s still in the development stage, and it will be published in the next version of our documentation, but you may want to look at it and implement your custom function in a similar way: https://codesandbox.io/s/github/handsontable/hyperformula-demos/tree/feature/issue-779/custom-functions
Does it solve your problem?
Sorry for the delay response. Thanks for the solution on custom function’s argument related issue.
I have verified this code in all way. It returns cell reference and named expression value. Thanks.
But when i use multiple params using comma it returns error.
Ex. =GREET(A1) working
=GREET(A1,12345) working
=GREET(A1,‘PRODUCT’) It is not working.
i have using this for multiple param,
GreetingsPlugin.implementedFunctions = {
GREET: {
method: “greet”,
parameters: [{ argumentType: “STRING” }, { argumentType: “STRING” }]
}
};
I’ve asked our Hyperfomula developer for an advice on this. I’ll get back to you when I have more info.
Sure. thank you @adrian.szymanski
HyperFormula accepts string parameters in double-quotes. Try this:
=GREET(A1, "PRODUCT")
I missed to pass multiple params.
ex:
greet(ast, state) {
return this.runFunction(
ast.args,
state,
this.metadata(“GREET”),
(username,param) => {
if (!username) {
return new CellError(‘VALUE’);
}
return `👋 Hello, ${username}!`;
}
It is working and returns value as expected. It is helped me a lots.
Thank you @adrian.szymanski
That’s great. I’m glad that we could help!