【发布时间】:2017-09-12 06:05:54
【问题描述】:
我有表单响应表,我想在read only 模式下创建一些行。如何使用 Google Apps 脚本或任何替代方法来实现它。
谢谢!
【问题讨论】:
-
关注这个documentation,对你有帮助。
标签: google-apps-script spreadsheet
我有表单响应表,我想在read only 模式下创建一些行。如何使用 Google Apps 脚本或任何替代方法来实现它。
谢谢!
【问题讨论】:
标签: google-apps-script spreadsheet
解决这个问题的两种方法:
应用脚本
您想使用电子表格 (documentation) 的 Protection 类。这允许访问内置的单元保护机制。 这是将范围设为只读的文档示例:
// 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 菜单从表格应用程序中访问单元格和范围保护机制。选择Data>Protect sheets and ranges...,然后在侧边栏设置权限。
【讨论】: