应用程序脚本中隐藏纸的副本
我有这个代码片段,可以在文档中副本进行副本。我不知道它是否制作了隐藏纸的副本,隐藏板的_temp副本没有出现在界面中,但我想它们也被隐藏了。如果副本进行了副本,我如何修改代码不复制隐藏的床单?我的文档中有很多隐藏的SH,它可以节省时间并避免崩溃。
var ss = SpreadsheetApp.openById(spreadsheetId);
var tempSheets = ss.getSheets().map(function(sheet) {
var dstSheet = sheet.copyTo(ss).setName(sheet.getSheetName() + "_temp");
var src = dstSheet.getDataRange();
src.copyTo(src, {contentsOnly: true});
return dstSheet;
});
谢谢
I have this fragment of code that make a copy of each Sheet in the document. I don't know if it makes copies of Hidden Sheets, the _temp copy of the hidden sheets do not appear in the interface but i suppose they are also hidden. In case it does the copies, how could I modify the code to not copy hidden sheets? I have a lot of hidden sh in my document and it could save time and avoid crashes.
var ss = SpreadsheetApp.openById(spreadsheetId);
var tempSheets = ss.getSheets().map(function(sheet) {
var dstSheet = sheet.copyTo(ss).setName(sheet.getSheetName() + "_temp");
var src = dstSheet.getDataRange();
src.copyTo(src, {contentsOnly: true});
return dstSheet;
});
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该有效:
sheet.issheethidend()
将返回true
如果表格被隐藏,false
否则。我们首先将列表过滤到非隐藏板,然后仅复制其余的床单。This should work:
sheet.isSheetHidden()
will returntrue
if the sheet is hidden, andfalse
otherwise. We first filter the list to non-hidden sheets, and then only copy the rest of the sheets.复制未底面的床单
Copy unhidden sheets