Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 从google apps scrip调用客户端函数_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 从google apps scrip调用客户端函数

Google apps script 从google apps scrip调用客户端函数,google-apps-script,google-sheets,Google Apps Script,Google Sheets,如何从GoogleApps脚本(或者如果可能,从GoogleSheets)调用客户端函数 js.html: function clientFunc (a, b) { return a+b } function server-func (x, y) { return somehowCall.clientFunc(x, y) } code.gs: function clientFunc (a, b) { return a+b } function server-func

如何从GoogleApps脚本(或者如果可能,从GoogleSheets)调用客户端函数

js.html:

function clientFunc (a, b) {
    return a+b
}
function server-func (x, y) {
    return somehowCall.clientFunc(x, y)
}
code.gs:

function clientFunc (a, b) {
    return a+b
}
function server-func (x, y) {
    return somehowCall.clientFunc(x, y)
}
在google.sheet单元格中
A3

= serverFunc (A1, A2) // or clientFunc (A1, A2)
我怎样才能做到这一点。可能吗?若并没有,那个么在使用“所有应用程序”脚本在谷歌服务器上执行我的应用程序时,将一些重负载指定给客户端的最佳方法是什么

PS:我知道
google.script.run
,它通过客户端调用运行服务器端函数。我想要与此功能相反的功能。

这是不可能的。
但即使这样,也帮不了你

我理解的最终目标是将一些繁重的负载委托给客户端。
通过从服务器端调用
clientFunc
,可以同时加载服务器和客户端

另外,当编写被调用的函数时,比如
=serverFunc(A1,A2)
,它们将始终是服务器函数。那里不可能有客户端函数

如果希望脚本运行得更快,请执行其他类型的优化,例如最小化对
电子表格应用程序
(或其他LIB)的调用。
查找调用
openById
getSheetByName
getRange
等的位置,并确保避免从循环调用它们,并尽量减少这些调用

那些才是真正慢的。任何其他纯javascript操作都会运行得非常快