0
私はGoogleシートで保護されていない範囲を設定しようとしていますが、同時にいくつかの範囲で保護を解除できます。したがって、私はそれらを配列に格納し、同時にすべての保護を解除したいと思います。しかし、私はprotection.setUnprotectedRangesステートメント(以下のコードで***で示されている)で配列を使用するのに問題があります。protection.setUnprotectedRanges - Google Apps Script
配列内のすべての要素を宣言することなく配列を使用できますか?
おかげ
function myFunction2() {
var sheet = SpreadsheetApp.getActiveSheet();
var protection = sheet.protect().setDescription('Protect Sheet');
var unprotected = new Array(26);
unprotected[0] = sheet.getRange(1,1,10,1);
unprotected[1] = sheet.getRange(1,5,10,2);
unprotected[2] = sheet.getRange(1,20,10,2);
protection.setUnprotectedRanges([unprotected[]]); // *** How to I use the whole array with setUnprotectedRanges, without declaring every element within the array in the statement (as below)
//protection.setUnprotectedRanges([unprotected[0],unprotected[1]]); // don't want to use this method
// 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.
var me = Session.getEffectiveUser();
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
}
パーフェクトにそれの名前
unprotected
によって全体arrayを渡して、素晴らしい作品!ありがとうございました –