本文介绍了Google电子表格 - 删除范围保护时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的脚本,但是我无法解决它,因为一些奇怪的原因?? !!!使我抓狂。

Here's my script, but I can't get it to work for some weird reason??!!! Driving me nuts.

function removeThenSetProtection() {
  // Remove all range protections in the spreadsheet that the user has
  //permission to edit.
  var ss = SpreadsheetApp.getActive();
  var protections = ss.getProtections(SpreadsheetApp.ProtectionType.SHEET);

  for (var i = 0; i < protections.length; i++) {
    var protection = protections[i];
    if (protection.canEdit()) {
      protection.remove();
    }
  }
}


推荐答案

更改:

var protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE);

收件人:

var protections = ss.getProtections(SpreadsheetApp.ProtectionType.SHEET);

通过这种方式,您可以放心,您将获得所有受保护内容的参考,并且未来的冲突不会发生。

That way, you'll be assured that you are getting a reference to everything that is protected, and future conflicts don't happen.

这篇关于Google电子表格 - 删除范围保护时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 03:10