问题描述
我有一些我需要保护的表格,除了某些范围。
是否可以使用脚本来完成此任务,因为我有几张工作表和工作表内的多个范围,我需要对这些范围进行取消保护,以便工作人员可以编辑工作表。
我需要离开不受保护的范围是重复的,所以我希望它是可行的。我会在我给你的示例工作表中填写我希望保留UNPROTECTED的范围。
可以查看其中一张表的示例。
N4:V26,N30:V52,N56: V78等等。基本上需要保护表格的其余部分。不受保护的范围,列保持不变,但每个不受保护的范围由被保护的三行分隔。
如果有人可以帮助完成这个脚本,感激,因为它可以节省我几个小时的时间,手动保护这些范围在很多床单上。
问候Matt
是的,您可以使用 Protection
类来完成此操作。您将首先使用 var protection = sheet.protect()
保护整个工作表,然后使用保护解除您希望人们可以编辑的范围.setUnprotectedRanges([ranges])
,其中 [ranges]
是一个范围对象数组。您可以在中阅读更多相关信息。
I have a number of sheets which I need to protect except for certain ranges.
Is it possible to do this with a script, as I have several sheets, and many ranges within the sheet which I need to be unprotected so staff can edit the sheets.
The ranges I need to leave unprotected are repetitive, so I'm hoping it's doable. I will fill the ranges I want to remain UNPROTECTED with YELLOW on the example sheet I'll give you.
An example of one of the sheets can be viewed here.
As mentioned, I need to protect the whole sheet, apart from these ranges...
N4:V26,N30:V52,N56:V78 etc etc. Basically the rest of the sheet needs to be protected. The unprotected ranges, the columns stay the same, but each unprotected range is separated by three rows which are protected.
If anyone can help with this script I'd be very grateful as it will save me hours of time manually protecting these ranges over many sheets.
Regards Matt
Yes, you can accomplish this using the Protection
class. You would first protect the whole sheet using var protection = sheet.protect()
, then unprotect the ranges you want people to be able to edit using protection.setUnprotectedRanges([ranges])
, where [ranges]
is an array of range objects. You can read more about it in the Google Apps Script Class Protection documentation.
这篇关于使用谷歌应用脚本保护范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!