Is it possible to call any of the Google Sheets formulas from within your own Google Apps script custom function? If so, how?
It obviously doesn't work to merely use the formula name like you would inside the sheet. Like this, which is what I was hoping would work:
function myCustomFunction() {
return TDIST(1,30,1); // calling =myCustomFunction() does not work due to TDIST giving a ReferenceError, even though =TDIST(1,30,1) works inside the spreadsheet
}
But since Google's built-in formulas probably rely on some JS implemented functions, it would be strange if there wasn't an API so that we could reuse those functions easily. I've looked at the Google Sheets API reference, but it seems made for calling your custom functions from external services. It seems you may call Google's own formulas through such a POST request. But that seems terribly cumbersome, when you ought to be able to refer to them directly from within your custom script which is tied to the specific Google Sheet environment anyway. If not, then what is the least roundabout way of using those inbuilt formula functions from within a custom function?
myCustomFunction
as if it's a custom function called from spreadsheet gives a different view. Regardless, the answer is the same. Not possible. – TheMastermyCustomFunction
is typically called from the spreadsheet, yes. I don't need to evaluate an expression (like=1+2
), and using a genericeval()
would be way too broad for what I'm thinking. I'm sure they haven't implemented that because of security concerns. I was hoping the functions the default formulas use were exposed in some sort of API.. Thanks for your input, tho. – Magne