[英]Google Spreadsheet User permission with Google Apps Script
I am not able to replicate the result of these actions (see pictures) WITH GOOGLE APPS SCRIPT CODE.我无法使用 GOOGLE 应用程序脚本代码复制这些操作的结果(见图片)。
Here are the actions:以下是操作:
Open a SpreadSheet with Google Spreadsheets使用 Google 电子表格打开电子表格
Right click -> Protect Range...右键单击 -> 保护范围...
Click on this点击这个
Then click on this然后点击这个
And和
I had NO success by trying this code:尝试以下代码没有成功:
SpreadsheetApp.addEditor('theEmailThatIWantToEnabled@email.com');
Here the solution of this problem.这里是这个问题的解决方案。
In my specific case the permissions were "by sheets" and NOT "by ranges" .在我的特定情况下,权限是“按工作表”而不是“按范围” 。
So here a small working code:所以这里有一个小的工作代码:
var ss = SpreadsheetApp.getActive();
var protections = ss.getProtections(SpreadsheetApp.ProtectionType.SHEET);
for (var i = 0; i < protections.length; i++) {
protections[i].addEditor('theEmailYouWantEnabled@email.com');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.