[英]Google Spreadsheet script “Cell reference out of range”
I have a range in a google spreadsheet script. 我在Google电子表格脚本中有一个范围。
var thisClientOutputRange = outputSheet.getRange(thisClientStartRow,thisClientStartColumn, monthsToSim + 3, 1);
Logger.log(thisClientOutputRange.getA1Notation());
The output is: 输出为:
[15-10-29 18:43:06:461 GALT] B7:B57
Which is exactly the range I intended to address for this specific client (currently looping on in a for loop). 这正是我要针对此特定客户端解决的范围(当前在for循环中循环)。
I can do 我可以
var thisClientOutputNameRange = thisClientOutputRange.getCell(1,1);
thisClientOutputNameRange.setValue(thisClientName);
And I can see the value correctly at B7
. 而且我可以在
B7
正确看到该值。 Now the problem is if I try to do 现在的问题是,如果我尝试去做
var thisClientOutputNameRange = thisClientOutputRange.getCell(1,2);
I get the error Cell reference out of range
at exactly this line. 我在此行得到错误的
Cell reference out of range
。 I need to write something at C7
. 我需要在
C7
写点东西。
According to the getCell documentation: 根据getCell文档:
var range = sheet.getRange("B2:D4");
// The row and column here are relative to the range.
//这里的行和列是相对于范围的。
//
getCell(1,1)
in this code returns the cell at B2, B2//此代码中的
getCell(1,1)
返回B2,B2处的单元格
I must have a very stupid mistake, but I can't find it. 我一定有一个非常愚蠢的错误,但是我找不到。 Any idea what could be going wrong with my logic?
知道我的逻辑有什么问题吗?
thanks 谢谢
The range's getCell(row,column) method returns a cell from the range. 范围的getCell(row,column)方法返回范围中的一个单元格。 The row and column coordinates are relative to the range.
行和列的坐标是相对于范围的。 In your example of getCell(1,2), row=1 and column=2 represents the cell at the first row and second column of the range.
在您的getCell(1,2)示例中,row = 1和column = 2表示范围的第一行和第二列的单元格。 However, the range B7:B57 only has one column.
但是,范围B7:B57只有一列。 Thus, the cell reference is outside of the range.
因此,单元格引用超出了范围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.