gpt4 book ai didi

google-apps-script - 无权使用 setFormula Google appS 脚本

转载 作者:行者123 更新时间:2023-12-04 15:43:35 25 4
gpt4 key购买 nike

我正在尝试制作一个脚本,其中包含单元格的地址。

在 excel 中,我有这段代码:

Function pos(cell As Range)
pos = cell.Address
End Function

它给了我单元格的地址。

在 Google 应用脚本上我尝试了这段代码:

function addrss(cel){
var spreadsheet = SpreadsheetApp.getActive();
var cc = spreadsheet.getCurrentCell().activate();
c = cc.setFormula('=ADDRESS(COLUMN('+cel+');ROW('+cel+'))');
return c;
}

function pos(cell){
var ad = addrss(cell);
return ad;
}

但是会收到一条错误消息“您没有调用 setFormula 的权限”。

有没有办法获得此权限或解决方法?

最佳答案

自定义函数不能用于设置单元格公式,它们只能用于返回值/值数组。引用Custom Functions in Google Sheets

要自动设置单元格的公式而不是使用自定义函数,您可以使用调用自的函数:

  • 自定义菜单
  • 按钮
  • 对话框或边栏
  • 简单或可安装的触发器

资源

相关

关于google-apps-script - 无权使用 setFormula Google appS 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56860310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com