0

我有一个Google云端硬盘文件夹,里面有30多个Google表格。在每张工作表中,我有5个以上的标签,每个标签至少有一组受保护的单元格或标签本身。我想知道,是否可以将受保护单元的所有这些权限作为文本提供给一个Google表单,以便能够快速查看并可能管理权限。然后,我的长期目标就是直接从该Google表单管理受保护的单元格。我一直在寻找,但还没有找到任何资源让我走上正轨。在Google表格中管理Google受保护的单元格

回答

1

我所著这个剧本,让您想要的任务,

运行,你需要打开一个电子表格,或ceate一个新的,然后 转到工具 - >脚本编辑器创建脚本它,然后复制/粘贴代码。

更改“#########################”为您的容器文件夹的ID,以确定您的文件夹的ID你可以打开一个文件夹,然后复制对应的ID https://drive.google.com/drive/folders/#########################

的URL部分,你之后添加菜单,你需要刷新才能看到它。

使用方法:点击定制实用程序 - >获取permisions列表这里,那么它会创建“纸#”,将拥有所有的信息

这里是代码:

function onOpen(){ 
    var ui = SpreadsheetApp.getUi(); 
    ui.createMenu('Custom Utilities').addItem('Get permisions list Here','testfunction').addToUi(); 
} 

function testfunction() { 
    //Add a new sheet in the current Spreadsheet 
    var activeSheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet().activate(); 
    activeSheet.appendRow(['FileName','ID','Protection Description','Range','Type','Users']); 
    activeSheet.getRange("A1:F1").setFontWeight('bold'); 

    //get all the Google Spreadsheet's files 
    var files = DriveApp.getFolderById("#########################").getFilesByType(MimeType.GOOGLE_SHEETS); 
    while (files.hasNext()) { 
    var file = files.next(); 
    var ss = SpreadsheetApp.openById(file.getId()); 

    //get the permisions in the current file, and print the data to the previous created sheet 
    var protectionsRange = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE); 
    for (var i = 0; i < protectionsRange.length; i++) { 
     var protection = protectionsRange[i]; 

     activeSheet.appendRow([file.getName(),file.getId(),protection.getDescription(),protection.getRange().getA1Notation(),protection.getProtectionType(),protection.getEditors().join(";")]); 
     //Logger.log(file.getName() + " | " + file.getId() + " \n| " + protection.getDescription() + " | " + protection.getRange().getA1Notation() + " | " + protection.getProtectionType() + " | " + protection.getEditors().join(";")); 
    } 
    var protectionsSheet = ss.getProtections(SpreadsheetApp.ProtectionType.SHEET); 
    for (var i = 0; i < protectionsSheet.length; i++) { 
     var protection = protectionsSheet[i]; 
     activeSheet.appendRow([file.getName(),file.getId(),protection.getDescription(),protection.getRange().getA1Notation(),protection.getProtectionType(),protection.getEditors().join(";")]); 
     //Logger.log(file.getName() + " | " + file.getId() + " \n| " + protection.getDescription() + " | " + protection.getRange().getA1Notation() + " | " + protection.getProtectionType() + " | " + protection.getEditors().join(";")); 
    } 
    } 
} 
相关问题