简体   繁体   English

使用 Google Apps 脚本隐藏行

[英]Hide Rows with Google Apps Script

I'm new to using Apps Script.我刚开始使用 Apps 脚本。 I'm trying to automate a function to hide empty rows based on a dropdown selection but it does not seem to fully function. I get one to work but when I select another class it does not hide the correct rows.我正在尝试自动执行 function 以根据下拉选择隐藏空行,但它似乎并不完全 function。我得到一个工作但是当我 select 另一个 class 它没有隐藏正确的行。 It stays hiding the rows (35,2)它保持隐藏行 (35,2)

Please Help: Here is the script thanks:请帮助:这是脚本谢谢:

function hideRow()
{

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Attendance Register');
var dropDown = sheet.getRange("G12").getValue();

if(dropDown == "GED 211 Academic Writing")
{
sheet.hideRows(35,2);

}
else if(dropDown == "FS101 Freshman Seminar")
{
sheet.hideRows(24,13);

}

else if(dropDown == "GED000B Foundation English I")
{
sheet.hideRows(23,14);

}
else if(dropDown == "GED001 Foundation Mathematics II")
{
sheet.hideRows(22,15);

}
else if(dropDown == "GED003 Fundamentals in Hospitality and Tourism")
{
sheet.hideRows(24,13);

}
else
{

}


}

You need to call showRows() function at the start of your script to unhide all the rows first.您需要在脚本开头调用showRows() function 以首先取消隐藏所有行。

https://developers.google.com/apps-script/reference/spreadsheet/sheet#showrowsrowindex https://developers.google.com/apps-script/reference/spreadsheet/sheet#showrowsrowindex

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM