Google脚本setValue权限 [英] Google Script setValue permission

查看:152
本文介绍了Google脚本setValue权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 函数exampleFunction(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range1 = sheet.getRange(A1);
var value1 = range1.getValue();
value1 + = 1;
range1.setValue(2);
返回值1;



$ b $ p
$ b如果我试图用这个函数来影响单元格,这个错误就会出现:


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


你知道我该如何做到这一点吗?我真的希望受影响的单元格取得单元格A1的值并增加A1 +1的值。

谢谢

他们在英寸在大多数情况下,单元格A1中的自定义函数不能修改单元格A5。但是,如果自定义函数返回双数组,则结果会溢出包含该函数的单元格,并填充包含自定义函数的单元格的右下方的单元格。您可以使用包含return [[1,2],[3,4]];。



参考的自定义函数对此进行测试:电子表格中的自定义功能


I'm trying to set some value to a cell in a google docs 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'm trying to affect a cell with this function this error appears:

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

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

Thank you

解决方案

from the documentation :

Custom functions return values, but they cannot set values outside the cells they are in. In most circumstances, a custom function in cell A1 cannot modify cell A5. However, if a custom function returns a double array, the results overflow the cell containing the function and fill the cells below and to the right of the cell containing the custom function. You can test this with a custom function containing return [[1,2],[3,4]];.

reference : Custom Functions in Spreadsheets

这篇关于Google脚本setValue权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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