自定义功能会引发“您没有setValue所需的权限",错误 [英] Custom function throws a "You do not have the permission required to setValue" error

本文介绍了自定义功能会引发“您没有setValue所需的权限",错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为Google Spreadsheet中的单元格设置一些值:

I am trying to set some value to a cell in a Google Spreadsheet:

    function exampleFunction() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var sheet = ss.getSheets()[0];
      var range1 = sheet.getRange("A1");
      var value1 = range1.getValue();
      value1+=1;
      range1.setValue(2);
      return value1;
    }

如果我尝试使用此功能影响单元格,则会出现此错误:

If I am trying to affect a cell with this function, this error appears:

您没有setValue所需的权限. (第10行,文件"ddd")

You do not have the permission required to setValue. (line 10, file "ddd")

您知道我该怎么做吗?我实际上希望受影响的单元格采用单元格A1的值并将A1的值增加1.

Do you know how I could make that possible? I actually want the affected cell to take the value of the cell A1 and increase the value of A1 by 1.

推荐答案

:

自定义函数返回值,但是它们无法在其所在的单元格外部设置值.在大多数情况下,单元格A1中的自定义函数无法修改单元格A5.但是,如果自定义函数返回一个double数组,则结果将溢出包含该函数的单元格,并填充包含该自定义函数的单元格下方和右侧的单元格.您可以使用包含return [[1,2 ,, [3,4]];的自定义函数进行测试.

参考:电子表格中的自定义函数

这篇关于自定义功能会引发“您没有setValue所需的权限",错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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