Getting the row number within a custom function

In the spreadsheet component, I am creating custom functions using registerMathMethod()

One such function ROW() needs to return the row number of the cell from which the function is called. Without passing any parameter to the function.

The parent scope and {this} of the custom function code doesn’t provide any such context. How can I figure out from which row the function is being called?

So:
=ROW() in cell A1 should return 1
=ROW() in cell A2 should return 2
=ROW() in cell C3 should return 3

Obviously this needs to recalculate following any row insert or delete, or cellValue change etc. I like to do this purely within the custom function, without having to create custom eventHandlers on the sheet.

Excel has the same ROW() function, which I need to mimic:
https://support.microsoft.com/en-us/office/row-function-3a63b74a-c4d0-4093-b49a-e76eb49a6d8d

Hello @JohanSmith,

Unfortunately, now it is impossible to do this because only the values of the cells come to the called method.

We added this to the list of features and in future versions, we will try to implement it.

hi Dima, thanks, if you could add this in a future release (passing that context into the scope of the called function), that would be useful.