防止删除可被许多用户编辑的工作表中的复选框 [英] Prevent deletion of checkbox in sheet editable by many users

查看:49
本文介绍了防止删除可被许多用户编辑的工作表中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在工作表中使用复选框(它们本身的功能正是我所需要的。)

I am using checkboxes in a sheet (and their functionality in themselves are exactly what I need).

我遇到的问题是,能够编辑工作表,有时(错误地)删除复选框,而不是简单地选中/取消选中复选框。

The problems I am having is that the users who are able to edit the sheet, sometime (by mistake) delete the checkbox instead of simply checking/un-checking the checkbox.

因此,我希望用户使用复选框,但无法删除它们。

Hence, I want the users to use the checkboxes, but not be able to delete them.

这有可能吗?

仅供参考:无法

推荐答案

这里有一个示例,说明如何使用 onOpen触发器

Here you have an example on how to achive it using onOpen triggers

function onOpen(e) 
{
  var range = SpreadsheetApp.getActive().getSheets()[0].getRange(1,4,5);
  var values = range.getValues();

  for ( var val in values ) {
    if( values[val] != true && values[val] != false ) {
      values[val]= false;
    }
  }

  range.insertCheckboxes(values);
}

您必须指定复选框的位置,在此处提供的代码示例中是5个,从第1行到第5行,它们放在第4列,即D。

You have to specify where are the checkboxes placed, in the code example provided there are 5 of them, starting from row 1 to row 5, and they are placed on the 4th column, so called D.

这是在getRange(1, 4,5)函数:

This is specified on the getRange(1,4,5) function:

getRange(InitialRow,初始列,行数)

有关使用getRange()的更多文档,请使用以下引用

for more documentation around the use of getRange() use the following reference.

此onOpen函数将在每次打开电子表格时执行,如果在指定的字段上没有 false true 语句,这意味着我们以某种方式丢失了复选框,因此将再次介绍它们。

This onOpen function will be executed every time that the spreadsheet is opened, and if on the specified fields there aren't false or true statements, it means that we lost the checkbox somehow, so it will introduce them again.

这篇关于防止删除可被许多用户编辑的工作表中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆