使用Google Apps脚本在Google表格中创建新表格 [英] Create a new sheet in a Google Sheets with Google Apps Script
本文介绍了使用Google Apps脚本在Google表格中创建新表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Google Apps脚本在Google表格中创建新的表格?
How to create a new sheet in a Google Sheets with Google Apps Script?
我知道这似乎很明显,但是我只想创建一个具有特定名称的新工作表.
I know it seems obvious but I just want to create a new sheet with a specific name.
推荐答案
令人惊讶的是,我没有找到清晰,快速的答案.
Surprisingly I didn't find any clear and quick answer.
这是我的代码:
function onOpen() {
var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var yourNewSheet = activeSpreadsheet.getSheetByName("Name of your new sheet");
if (yourNewSheet != null) {
activeSpreadsheet.deleteSheet(yourNewSheet);
}
yourNewSheet = activeSpreadsheet.insertSheet();
yourNewSheet.setName("Name of your new sheet");
}
最后,请注意,此新工作表将自动成为活动工作表.
Finally, note that this new sheet will be automatically the active one.
这篇关于使用Google Apps脚本在Google表格中创建新表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文