Google apps script 如何使用GoogleApps脚本在电子表格中创建只读行?
我有表单响应表,我想在Google apps script 如何使用GoogleApps脚本在电子表格中创建只读行?,google-apps-script,spreadsheet,Google Apps Script,Spreadsheet,我有表单响应表,我想在只读模式下创建一些行。我如何使用谷歌应用程序脚本或任何其他方法来实现它 谢谢大家! 解决此问题的两种方法: 应用程序脚本 您希望使用电子表格()的保护类。这允许访问内置的单元保护机制。 以下是文档中用于使范围只读的示例: // Protect range A1:B10, then remove all other users from the list of editors. var ss = SpreadsheetApp.getActive(); var range
只读模式下创建一些行。我如何使用谷歌应用程序脚本或任何其他方法来实现它
谢谢大家! 解决此问题的两种方法:
应用程序脚本
您希望使用电子表格()的保护类。这允许访问内置的单元保护机制。
以下是文档中用于使范围只读的示例:
// Protect range A1:B10, then remove all other users from the list of editors.
var ss = SpreadsheetApp.getActive();
var range = ss.getRange('A1:B10');
var protection = range.protect().setDescription('Sample protected range');
// Ensure the current user is an editor before removing others.
// Otherwise, if the user's edit permission comes from a group,
// the script will throw an exception upon removing the group.
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
// Now the range is not editable by anyone.
// Just add yourself back to the editors list if necessary.
protection.addEditor(Session.getEffectiveUser());
在床单应用程序中
您可以通过Data
菜单从Sheets应用程序中访问单元格和范围保护机制。选择Data
保护工作表和范围…
,然后在侧栏中设置权限。按照此操作,将对您有所帮助。