如何在自定义函数中调用Google表格公式? [英] How to call a Google Sheet formula from within a custom function?

查看:178
本文介绍了如何在自定义函数中调用Google表格公式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以调用任何 Google表格公式在您自己的Google Apps脚本自定义功能中?如果可以,怎么办?

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
}

但是,由于Google的内置公式可能依赖于JS实现的某些功能,因此如果没有API以便我们可以轻松地重用这些功能,那将很奇怪.我查看了 Google表格API参考,但它似乎是为从外部服务调用您的自定义函数.看来您可以通过这样的POST请求调用Google自己的公式.但是,当您应该能够直接从与特定Google Sheet环境相关联的自定义脚本中引用它们时,这似乎非常麻烦.如果不是,那么从自定义函数中使用那些内置公式函数的最小回旋方式是什么?

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?

推荐答案

这是功能自2011年以来请求,但Google引用了团队内部问题拒绝了该请求.

This has been a feature request since 2011 and has been declined by Google citing inter team issues.

状态:无法通过ev .... @ google.com

Status: Won't Fix (Infeasible) by ev....@google.com

我们已向电子表格小组提出要求,并将其标记为不会解决".现在.

We have requested this of the Spreadsheet team, and are marking as "Won't Fix" for now.

显然,电子表格团队尚未回复.相关产品论坛帖子指出Google无意集成电子表格脚本功能.

Apparently, The spreadsheet team hasn't responded yet. A related product forum post states that Google has no intention of integrating spreadsheet functions with scripts.

这篇关于如何在自定义函数中调用Google表格公式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆