Ale*_*dre 6 google-sheets google-apps-script custom-function google-sheets-formula
我正在尝试制作一个脚本,其中包含单元格的地址。
在Excel中,我有这样的代码:
Function pos(cell As Range)
pos = cell.Address
End Function
Run Code Online (Sandbox Code Playgroud)
它给了我单元格的地址。
在 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;
}
Run Code Online (Sandbox Code Playgroud)
但收到错误消息“您无权调用 setFormula”。
有没有办法获得此许可或解决方法?
自定义函数不能用于设置单元格公式,它们只能用于返回值/值数组。参考号 Google 表格中的自定义函数
要自动设置单元格的公式而不是使用自定义函数,您可以使用从以下位置调用的函数:
资源
有关的
| 归档时间: |
|
| 查看次数: |
4790 次 |
| 最近记录: |