是否可以在谷歌脚本中引用离散范围? [英] Is it possible to reference discrete ranges in google scripts?
问题描述
函数getGrainWeights(){$ b我有一个谷歌脚本函数,它使我从谷歌电子表格范围内。 $ b var ss = SpreadsheetApp.getActiveSpreadsheet();
return range = ss.getRangeByName(Brew_Grains);
}
然后,该范围将由另一个函数处理,该函数会修改并上传范围。
Brew_Grains是我的电子表格中的一个命名范围,但我想用离散范围替换它,例如B2,C3,D10等。这是可能的,还是有一些解决方法?
干杯
您可通过以下方式获取范围,除了 getRangeByName(name)。
您可以找到文档
a>。 更新
解决方法如:
...
var ss = SpreadsheetApp.getActiveSpreadsheet()。getSheets()[0] ;
var ranges = [];
var range = ss.getRange('B2:C3');
ranges.push(range);
range = ss.getRange('D10');
ranges.push(range);
processingFunction(ranges);
...
然后,您可以将数组(范围)传递给任何其他函数处理。
I have a google script function that gets me a range from a google spreadsheet.
function getGrainWeights() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
return range = ss.getRangeByName("Brew_Grains");
}
This range is then processed by another function which modifies and upadtes the values in the range.
"Brew_Grains" is a named range in my spreadsheet but I would like to replace it with a discrete range such as "B2,C3,D10" etc. Is this possible, or is there some workaround? Cheers
You have the following ways to get a range, in addition to the named range used getRangeByName(name).
You can find the documentation.
UPDATE
A workaround to what you want to do can be something like:
...
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
var ranges = [];
var range = ss.getRange('B2:C3');
ranges.push(range);
range = ss.getRange('D10');
ranges.push(range);
processingFunction(ranges);
...
You can then pass the array (ranges) to any other function for processing.
这篇关于是否可以在谷歌脚本中引用离散范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!