列出Google表格中的图表名称并跳过前两个 [英] List names of sheets in Google Sheets and skip the first two
问题描述
我找到了代码来列出Google表格中所有工作表的名称(来自此处 ): 我的问题是如何修改脚本以跳过前两个工作表名称,并开始填充单元格中的脚本被调用的列表? 我试着改变 您有正确的想法,但您的输出数组将第一个项目放在第3位。相反,执行此操作: I found code to list the names of all the sheets in Google Sheets (from here): My question is how can I modify the script to skip the first two sheet names and begin populating the list in the cell where the script is called? I tried changing the You had the right idea, but your output array was placing the first item in position 3. Instead, do this:
这篇关于列出Google表格中的图表名称并跳过前两个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ b $ pre $ 函数SheetNames(){//用作自定义函数:= SheetNames(GoogleClock())
尝试{
var sheets = SpreadsheetApp.getActiveSpreadsheet()。getSheets()
var out = new Array(sheets.length + 1);
// out [0] = [Name,gid];
for(var i = 1; i< sheets.length + 1; i ++)out [i] = [sheets [i-1] .getName()];
退出
}
catch(err){
return#ERROR!
$ / code>
var i = 1
到
var i = 3
,并且跳过前两个工作表名称,但它也创建为空白单元格。如何跳过前两个工作表名称并且不创建任何空白单元格?
for(var i = 3; i< sheets .length + 1; i ++)out [i-2] = [sheets [i-1] .getName()];
function SheetNames() { // Usage as custom function: =SheetNames( GoogleClock() )
try {
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets()
var out = new Array( sheets.length+1 ) ;
//out[0] = [ "Name" , "gid" ];
for (var i = 1 ; i < sheets.length+1 ; i++ ) out[i] = [sheets[i-1].getName()];
return out
}
catch( err ) {
return "#ERROR!"
}
}
var i = 1
to var i = 3
and that did skip the first two sheet names but it also created to blank cells. How do I skip the first two sheet names and not create any blank cells?for (var i = 3 ; i < sheets.length+1 ; i++ ) out[i-2] = [sheets[i-1].getName()];