简体   繁体   English

Google AppScript 中的 hideSheet() 不隐藏工作表

[英]hideSheet() in Google AppScript not hiding sheet

I have a spreadsheet where I'm trying to hide two tabs:我有一个电子表格,我试图在其中隐藏两个选项卡:

function mySheet() {
// lots of stuff
   SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Raw Data").showSheet();
   SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Raw Data").hideSheet();
   SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Template").showSheet();
   SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Template").hideSheet();
}

Weirdly, "Template" gets hidden but "Raw Data" doesn't.奇怪的是,“模板”被隐藏了,但“原始数据”却没有。 I added the showSheet() method based on an answer to another question but it didn't make any difference.我根据对另一个问题的回答添加了 showSheet() 方法,但它没有任何区别。

What could be causing the hideSheet() method to not work?是什么导致 hideSheet() 方法不起作用? I checked spelling.我检查了拼写。 The "Raw Data" sheet is active at times during the script execution and should be hidden at the end of the function call to mySheet(). “原始数据”工作表在脚本执行期间有时处于活动状态,应在 function 调用 mySheet() 结束时隐藏。

Thanks for any thoughts!感谢您的任何想法!

This works for me这对我有用

function mySheet() {
   SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet0").showSheet();
   SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet0").hideSheet();
}

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

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