[英]Merging two variables in google apps script
function f(column) {
var i = 4;
}
I want to merge the "column" and "i" variable so I can use it as input in the spreadsheet function getRange(); 我想合并“ column”和“ i”变量,以便可以将其用作电子表格函数getRange()中的输入;
Is there a simple way to do this? 有没有简单的方法可以做到这一点?
Yup, there is a pretty simple way to do that: I'm guessing if column="A" and as i=4, you want to set something into A4 cell, then do like this: 是的,有一种非常简单的方法可以做到这一点:我猜是否column =“ A”且由于i = 4,您想在A4单元格中设置一些内容,然后执行以下操作:
function f(column)
{
var i = 4;
SpreadsheetApp.getActiveSpreadsheet().getRange(column+i).setValue("Hello World");
}
Here, getRange()
is accepting input value as "A4" or a1Notation. 在这里,
getRange()
接受输入值作为“ A4”或a1Notation。
I'm guessing that you want to use i as an offset along with column. 我猜想您想将i与列一起用作偏移量。
If so then 如果是这样
function f(column) {
var i = 4;
SpreadsheetApp.getActiveSheet().getRange("A1").offset(0, column + i, 1, 1);
}
would return a single cell, 4 + column to the right of A1. 将返回单个单元格,即A1右侧的4 +列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.