【发布时间】:2018-11-02 22:52:54
【问题描述】:
我对使用 Google 脚本非常陌生。我遇到了这个非常基本的问题,但我似乎找不到解释。 我在 Google 表格上编写了一个函数(从我想尝试代码的同一张表格中打开脚本编辑器)。事实证明,当我想使用我的功能时,Google 表格找不到它。这意味着,当我键入“=”加上函数名称时,我找不到它。我的代码如下:
function distance(origin,destination) {
var mapObj = Maps.newDirectionFinder()
mapObj.setMode(Maps.DirectionFinder.Mode.DRIVING)
//Set the Orgin
mapObj.setOrigin(origin)
//Set the Destination
mapObj.setDestination(destination)
//Retrieve the Distance
var directions = mapObj.getDirections();
var meters = directions["routes"][0]["legs"][0]["distance"]["value"];
}
我将不胜感激!
【问题讨论】:
-
确保你的自定义函数返回一些值来显示,见developers.google.com/apps-script/guides/sheets/…
标签: google-apps-script google-sheets jsdoc custom-function