gpt4 book ai didi

google-apps-script - 我可以使用脚本锁定特定的 Google Apps 工作表吗?

转载 作者:行者123 更新时间:2023-12-01 08:35:54 25 4
gpt4 key购买 nike

有没有办法使用脚本锁定特定的 Google Apps 工作表?

我有这段代码可以将当前电子表格重命名为您在输入框中输入的任何内容。

// The code below will rename the active sheet to what you enter in the input box
var myValue = Browser.inputBox("Enter: LastMonth - Year");
SpreadsheetApp.getActiveSpreadsheet().renameActiveSheet(myValue);
SpreadsheetApp.getActiveSpreadsheet().getRange("A1").setValue(myValue);

我可以在上面的代码中添加什么来锁定我刚刚重命名的同一个工作表,只允许我编辑该工作表。那可能吗?

最佳答案

// Enables sheet protection for  this sheet
var sheet = SpreadsheetApp.getActiveSheet();
var permissions = sheet.getSheetProtection();
permissions.setProtected(true);
sheet.setSheetProtection(permissions);

请参阅电子表格服务 - Class PageProtection

关于google-apps-script - 我可以使用脚本锁定特定的 Google Apps 工作表吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10622906/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com