I have my implementation of custom functions using HyperFormula and inside my function which gets the arguments I need to check how many rows/cols there are in my hot instance.
There is a hot variable inside there, but it seems to point to another hot instance, because it is always destroyed, while my hot instance isn’t.
Is there a way for me to pass my hot instance there or access in anyway?
Would it meet your requirements to use a variable in your custom formula (for example as a namedExpression) to a countRows() and countCols() methods’ results?
I think this would fit. I’ve create a new named expression following the docs, but now I have a doubt, how can I access my named expression inside my custom function class? Is there a easy way to get my hyperformula instance?
Question: do you plan to use the reference to get any non-data-related information? As in most of the cases we use namedExpressions to work on the data (example https://jsfiddle.net/jd62ykcv/)
To confirm, let’s say you have 10 rows so your formulas should look like =SUM(A1: maximum) where maximum is A + hot.countRows()? Or do I understand that wrong?
That is an interesting topic you have mentioned @thiagarajan
Please let me consult my colleague on that subject and come back to you after the weekend.
In general, it is a bad idea to try accessing Handsontable instance from HyperFormula. My reasons are:
The HyperFormula instance is created before the Handsontable instance
In our setup, HyperFormula is employed by Handsontable. Handsontable keeps an instance of HyperFormula. It would be bad, circular architecture to try accessing the “parent” instance of Handsontable from your instance of HyperFormula.
The naive (and bad) solution would be to access the data object that you passed to Handsontable by reference to count your rows: https://jsfiddle.net/warpech/fh25rvg8/
HyperFormula, being a calculation engine, actually keeps the whole representation of your data. Meaning: It already knows how many rows you have!
Here’s a good solution - example of a custom function volatile function with 0 parameters that returns the number of rows:
The best news for you is that you don’t really have to care about huge ranges as =SUM(A1:A999999999) or even infinity ranges when you supply just a column range (=SUM(A:A)), because they are automatically normalized by the engine to the size of your data graph.
Thank you so much for the answer, I’m going to implement in my project
I’m aware of the A:A feature, but some users just keep typing large numbers, which are being bad for my sheet performance, that’s way I need this extra check.