Korunan aralıklara ve sayfalara erişip bunları değiştirme Korunan aralık, statik bir hücre aralığını veya adlandırılmış bir aralığı koruyabilir. Korumalı bir sayfada korumasız bölgeler olabilir. Google E-Tablolar'ın eski sürümüyle oluşturulan e-tablolar için bunun yerine sınıfını kullanın.
Page
// Protect range A1:B10, then remove all other users from the list of editors. const ss = SpreadsheetApp.getActive(); const range = ss.getRange('A1:B10'); const 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 throws an exception // upon removing the group. const me = Session.getEffectiveUser(); protection.addEditor(me); protection.removeEditors(protection.getEditors()); if (protection.canDomainEdit()) { protection.setDomainEdit(false); }
// Remove all range protections in the spreadsheet that the user has permission // to edit. const ss = SpreadsheetApp.getActive(); const protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE); for (let i = 0; i < protections.length; i++) { const protection = protections[i]; if (protection.canEdit()) { protection.remove(); } }
// Protect the active sheet, then remove all other users from the list of // editors. const sheet = SpreadsheetApp.getActiveSheet(); const protection = sheet.protect().setDescription('Sample protected sheet'); // Ensure the current user is an editor before removing others. Otherwise, if // the user's edit permission comes from a group, the script throws an exception // upon removing the group. const me = Session.getEffectiveUser(); protection.addEditor(me); protection.removeEditors(protection.getEditors()); if (protection.canDomainEdit()) { protection.setDomainEdit(false); }
Yöntemler
| Yöntem | Dönüş türü | Kısa açıklama |
|---|---|---|
add | Protection | Belirtilen kullanıcıyı, korumalı sayfa veya aralığın düzenleyenler listesine ekler. |
add | Protection | Belirtilen kullanıcıyı, korumalı sayfa veya aralığın düzenleyenler listesine ekler. |
add | Protection | Belirtilen kullanıcı dizisini, korumalı sayfa veya aralığın düzenleyenler listesine ekler. |
add | Protection | Belirtilen hedef kitleyi, korumalı aralığın düzenleyeni olarak ekler. |
can | Boolean | E-tablonun sahibi olan alandaki tüm kullanıcıların korunan aralığı veya sayfayı düzenleme izni olup olmadığını belirler. |
can | Boolean | Kullanıcının korunan aralığı veya sayfayı düzenleme izni olup olmadığını belirler. |
get | String | Korunan aralığın veya sayfanın açıklamasını alır. |
get | User[] | Korunan aralık veya sayfanın düzenleyenler listesini alır. |
get | Protection | Korunan alanın türünü (RANGE veya SHEET) alır. |
get | Range | Korunan aralığı alır. |
get | String|null | Adlandırılmış bir aralıkla ilişkilendirilmişse korumalı aralığın adını alır. |
get | Target | Korumalı aralığı düzenleyebilecek hedef kitlelerin kimliklerini döndürür. |
get | Range[] | Korumalı bir sayfadaki korumasız aralıkların dizisini alır. |
is | Boolean | Korunan alanın "uyarı tabanlı" koruma kullanıp kullanmadığını belirler. |
remove() | void | Aralığın veya sayfanın korumasını kaldırır. |
remove | Protection | Belirtilen kullanıcıyı, korumalı sayfa veya aralığın düzenleyenler listesinden kaldırır. |
remove | Protection | Belirtilen kullanıcıyı, korumalı sayfa veya aralığın düzenleyenler listesinden kaldırır. |
remove | Protection | Belirtilen kullanıcı dizisini, korumalı sayfa veya aralığın düzenleyenler listesinden kaldırır. |
remove | Protection | Belirtilen hedef kitleyi korumalı aralığın düzenleyeni olarak kaldırır. |
set | Protection | Korunan aralığın veya sayfanın açıklamasını ayarlar. |
set | Protection | E-tablonun sahibi olan alandaki tüm kullanıcıların korumalı aralığı veya sayfayı düzenleme iznine sahip olup olmadığını ayarlar. |
set | Protection | Korumalı aralığı mevcut bir adlandırılmış aralıkla ilişkilendirir. |
set | Protection | Korunan aralığı ayarlar. |
set | Protection | Korumalı aralığı mevcut bir adlandırılmış aralıkla ilişkilendirir. |
set | Protection | Korumalı bir sayfadaki belirli aralık dizisinin korumasını kaldırır. |
set | Protection | Bu korumalı aralığın "uyarı tabanlı" koruma kullanıp kullanmadığını ayarlar. |
Ayrıntılı belgeler
add Editor(emailAddress)
Belirtilen kullanıcıyı, korumalı sayfa veya aralığın düzenleyenler listesine ekler. Bu yöntem, kullanıcıya e-tablonun kendisini düzenleme izni otomatik olarak vermez. Bunu yapmak için ek olarak Spreadsheet.addEditor(emailAddress) yöntemini çağırın.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Adds an editor to the spreadsheet using an email address. // TODO(developer): Replace the email address with a valid email. ss.addEditor('cloudysanfrancisco@gmail.com'); // Gets a sheet by its name and protects it. const sheet = ss.getSheetByName('Sheet1'); const sampleProtectedSheet = sheet.protect(); // Adds an editor of the protected sheet using an email address. // TODO(developer): Replace the email address with a valid email. sampleProtectedSheet.addEditor('cloudysanfrancisco@gmail.com'); // Gets the editors of the protected sheet. const editors = sampleProtectedSheet.getEditors(); // Logs the editors' email addresses to the console. for (const editor of editors) { console.log(editor.getEmail()); }
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
email | String | Eklenecek kullanıcının e-posta adresi. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
add Editor(user)
Belirtilen kullanıcıyı, korumalı sayfa veya aralığın düzenleyenler listesine ekler. Bu yöntem, kullanıcıya e-tablonun kendisini düzenleme izni otomatik olarak vermez. Bunu yapmak için ek olarak Spreadsheet.addEditor(user) yöntemini çağırın.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Protects the sheet. const sampleProtectedSheet = sheet.protect(); // Adds the active user as an editor of the protected sheet. sampleProtectedSheet.addEditor(Session.getActiveUser()); // Gets the editors of the protected sheet. const editors = sampleProtectedSheet.getEditors(); // Logs the editors' email addresses to the console. for (const editor of editors) { console.log(editor.getEmail()); }
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
user | User | Eklenecek kullanıcının temsili. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
add Editors(emailAddresses)
Belirtilen kullanıcı dizisini, korumalı sayfa veya aralığın düzenleyenler listesine ekler. Bu yöntem, kullanıcılara e-tablonun kendisini düzenleme izni otomatik olarak vermez. Bunu yapmak için ek olarak Spreadsheet.addEditors(emailAddresses) yöntemini çağırın.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Creates variables for the email addresses to add as editors. // TODO(developer): Replace the email addresses with valid ones. const TEST_EMAIL_1 = 'cloudysanfrancisco@gmail.com'; const TEST_EMAIL_2 = 'baklavainthebalkans@gmail.com'; // Protects the sheet. const sampleProtectedSheet = sheet.protect(); // Adds editors to the protected sheet using the email address variables. sampleProtectedSheet.addEditors([TEST_EMAIL_1, TEST_EMAIL_2]); // Gets the editors of the protected sheet. const editors = sampleProtectedSheet.getEditors(); // Logs the editors' email addresses to the console. for (const editor of editors) { console.log(editor.getEmail()); }
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
email | String[] | Eklenecek kullanıcıların e-posta adreslerinden oluşan bir dizi. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
add Target Audience(audienceId)
Belirtilen hedef kitleyi, korumalı aralığın düzenleyeni olarak ekler.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
audience | String | Eklenecek hedef kitlenin kimliği. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
can Domain Edit()
E-tablonun sahibi olan alandaki tüm kullanıcıların korunan aralığı veya sayfayı düzenleme izni olup olmadığını belirler. Kullanıcının korunan aralığı veya sayfayı düzenleme izni yoksa istisna oluşturur.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Protects the sheet. const sampleProtectedSheet = sheet.protect(); // Logs whether domain users have permission to edit the protected sheet to the // console. console.log(sampleProtectedSheet.canDomainEdit());
Return
E-tablonun sahibi olan alandaki tüm kullanıcıların korunan aralığı veya sayfayı düzenleme izni varsa Boolean, yoksa true.false
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
can Edit()
Kullanıcının korunan aralığı veya sayfayı düzenleme izni olup olmadığını belirler. E-tablo sahibi, korunan aralıkları ve sayfaları her zaman düzenleyebilir.
// Remove all range protections in the spreadsheet that the user has permission // to edit. const ss = SpreadsheetApp.getActive(); const protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE); for (let i = 0; i < protections.length; i++) { const protection = protections[i]; if (protection.canEdit()) { protection.remove(); } }
Return
Kullanıcının korunan aralığı veya sayfayı düzenleme izni varsa Boolean — true, yoksa false
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Description()
Korunan aralığın veya sayfanın açıklamasını alır. Açıklama ayarlanmamışsa bu yöntem boş bir dize döndürür.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Protects the sheet and sets the description. const sampleProtectedSheet = sheet.protect().setDescription('Sample sheet is protected'); // Gets the description of the protected sheet and logs it to the console. const sampleProtectedSheetDescription = sampleProtectedSheet.getDescription(); console.log(sampleProtectedSheetDescription);
Return
String: Korunan aralığın veya sayfanın açıklaması ya da açıklama ayarlanmamışsa boş bir dize.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Editors()
Korunan aralık veya sayfanın düzenleyenler listesini alır. Kullanıcının korunan aralığı veya sayfayı düzenleme izni yoksa istisna oluşturur.
// Protect the active sheet, then remove all other users from the list of // editors. const sheet = SpreadsheetApp.getActiveSheet(); const protection = sheet.protect().setDescription('Sample protected sheet'); // Ensure the current user is an editor before removing others. Otherwise, if // the user's edit permission comes from a group, the script throws an exception // upon removing the group. const me = Session.getEffectiveUser(); protection.addEditor(me); protection.removeEditors(protection.getEditors()); if (protection.canDomainEdit()) { protection.setDomainEdit(false); }
Return
User[]: Korumalı aralığı veya sayfayı düzenleme izni olan kullanıcı dizisi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Protection Type()
Korunan alanın türünü (RANGE veya SHEET) alır.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Protects the sheet. const sampleProtectedSheet = sheet.protect(); // Gets the type of the protected area. const protectionType = sampleProtectedSheet.getProtectionType(); // Logs 'SHEET'to the console since the type of the protected area is a sheet. console.log(protectionType.toString());
Return
Protection — Korunan alanın türü, RANGE veya SHEET.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Range()
Korunan aralığı alır. Koruma, aralık yerine sayfaya uygulanıyorsa bu yöntem, sayfanın tamamını kapsayan bir aralık döndürür.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range 'A1:B10' of Sheet1. const range = sheet.getRange('A1:B10'); // Makes cells A1:B10 a protected range. const sampleProtectedRange = range.protect(); // Gets the protected ranges on the sheet. const protections = sheet.getProtections(SpreadsheetApp.ProtectionType.RANGE); // Logs the A1 notation of the first protected range on the sheet. console.log(protections[0].getRange().getA1Notation());
Return
Range: Korunan aralık.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Range Name()
Adlandırılmış bir aralıkla ilişkilendirilmişse korumalı aralığın adını alır. Koruma, adlandırılmış bir aralıkla ilişkilendirilmemişse null değerini döndürür. Korumalı bir aralığı adlandırılmış bir aralıkla ilişkilendirmek için komut dosyalarının set işlevini açıkça çağırması gerektiğini unutmayın. Range işlevini çağırarak adlandırılmış bir aralık olan Range.protect() işlevinden koruma oluşturmak, set işlevi çağrılmadan bu aralıkları ilişkilendirmek için yeterli değildir. Ancak Google E-Tablolar kullanıcı arayüzünde adlandırılmış bir aralıktan korumalı aralık oluşturduğunuzda bu aralıklar otomatik olarak ilişkilendirilir.
// Protect a named range in a spreadsheet and log the name of the protected // range. const ss = SpreadsheetApp.getActive(); const range = ss.getRange('A1:B10'); const protection = range.protect(); ss.setNamedRange('Test', range); // Create a named range. protection.setRangeName( 'Test'); // Associate the protection with the named range. Logger.log( protection.getRangeName()); // Verify the name of the protected range.
Return
String|null — korunan adlandırılmış aralığın adı veya null korunan aralık adlandırılmış bir aralıkla ilişkilendirilmemişse
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Target Audiences()
Korumalı aralığı düzenleyebilecek hedef kitlelerin kimliklerini döndürür.
Return
Target: Hedef kitlelerin kimliklerinden oluşan bir dizi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Unprotected Ranges()
Korumalı bir sayfadaki korumasız aralıkların dizisini alır. Protection nesnesi, korunan bir sayfa yerine korunan bir aralığa karşılık geliyorsa bu yöntem boş bir dizi döndürür. Korumasız aralıkları değiştirmek için set kullanarak yeni bir aralık dizisi ayarlayın. Sayfanın tamamını yeniden korumak için boş bir dizi ayarlayın.
// Unprotect cells E2:F5 in addition to any other unprotected ranges in the // protected sheet. const sheet = SpreadsheetApp.getActiveSheet(); const protection = sheet.protect(); const unprotected = protection.getUnprotectedRanges(); unprotected.push(sheet.getRange('E2:F5')); protection.setUnprotectedRanges(unprotected);
Return
Range[]: Korunan bir sayfadaki korumasız aralık dizisi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
is Warning Only()
Korunan alanın "uyarı tabanlı" koruma kullanıp kullanmadığını belirler. Uyarı tabanlı koruma, kullanıcının düzenlemeyi onaylamasını isteyen bir uyarı istemi dışında, her kullanıcının alandaki verileri düzenleyebileceği anlamına gelir. Varsayılan olarak, korumalı aralıklar veya sayfalar uyarı tabanlı değildir. Uyarı durumuna geçmek için set kullanın.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Protects the sheet. const sampleProtectedSheet = sheet.protect(); // Sets the warning status for the protected sheet as true. sampleProtectedSheet.setWarningOnly(true); const protectedSheetWarningStatus = sampleProtectedSheet.isWarningOnly(); // Logs the warning status of the protected sheet to the console. console.log(protectedSheetWarningStatus);
Return
Korunan aralık veya sayfa yalnızca uyarı tabanlı koruma kullanıyorsa Boolean — true.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
remove()
Aralığın veya sayfanın korumasını kaldırır.
// Remove all range protections in the spreadsheet that the user has permission // to edit. const ss = SpreadsheetApp.getActive(); const protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE); for (let i = 0; i < protections.length; i++) { const protection = protections[i]; if (protection.canEdit()) { protection.remove(); } }
// Remove sheet protection from the active sheet, if the user has permission to // edit it. const sheet = SpreadsheetApp.getActiveSheet(); const protection = sheet.getProtections(SpreadsheetApp.ProtectionType.SHEET)[0]; if (protection?.canEdit()) { protection.remove(); }
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
remove Editor(emailAddress)
Belirtilen kullanıcıyı, korumalı sayfa veya aralığın düzenleyenler listesinden kaldırır. Kullanıcı, düzenleme izni olan bir Google Grubu'nun üyesiyse veya alandaki tüm kullanıcıların düzenleme izni varsa kullanıcının korunan alanı düzenleyebileceğini unutmayın. E-tablonun sahibi ve mevcut kullanıcı kaldırılamaz.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Creates a variable for an email address. // TODO(developer): Replace the email address with a valid one. const TEST_EMAIL = 'baklavainthebalkans@gmail.com'; // Protects the sheet. const sampleProtectedSheet = sheet.protect(); // Adds an editor to the protected sheet using the email address variable. sampleProtectedSheet.addEditor(TEST_EMAIL); // Removes the editor from the protected sheet using the email address variable. sampleProtectedSheet.removeEditor(TEST_EMAIL); // Gets the editors of the protected sheet. const editors = sampleProtectedSheet.getEditors(); // Logs the editors' email addresses to the console. for (const editor of editors) { console.log(editor.getEmail()); }
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
email | String | Kaldırılacak kullanıcının e-posta adresi. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
remove Editor(user)
Belirtilen kullanıcıyı, korumalı sayfa veya aralığın düzenleyenler listesinden kaldırır. Kullanıcının, düzenleme izni olan bir Google Grubu'nun üyesi olması veya alandaki tüm kullanıcıların düzenleme iznine sahip olması durumunda kullanıcının korunan alanı düzenlemeye devam edebileceğini unutmayın. Ne e-tablonun sahibi ne de mevcut kullanıcı kaldırılamaz.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets a sheet by its name. const sheet = ss.getSheetByName('Sheet1'); // Protects the sheet. const sampleProtectedSheet = sheet.protect(); // Removes the active user from the editors of the protected sheet. sampleProtectedSheet.removeEditor(Session.getActiveUser()); // Gets the editors of the protected sheet. const editors = sampleProtectedSheet.getEditors(); // Logs the editors' email addresses to the console. for (const editor of editors) { console.log(editor.getEmail()); }
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
user | User | Kaldırılacak kullanıcının temsili. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
remove Editors(emailAddresses)
Belirtilen kullanıcı dizisini, korumalı sayfa veya aralığın düzenleyenler listesinden kaldırır. Kullanıcılardan herhangi biri, düzenleme izni olan bir Google Grubu'nun üyesiyse veya alandaki tüm kullanıcıların düzenleme izni varsa bu kullanıcılar, korunan alanı düzenlemeye devam edebilir. E-tablonun sahibi veya mevcut kullanıcı kaldırılamaz.
// Protect the active sheet, then remove all other users from the list of // editors. const sheet = SpreadsheetApp.getActiveSheet(); const protection = sheet.protect().setDescription('Sample protected sheet'); // Ensure the current user is an editor before removing others. Otherwise, if // the user's edit permission comes from a group, the script throws an exception // upon removing the group. const me = Session.getEffectiveUser(); protection.addEditor(me); protection.removeEditors(protection.getEditors()); if (protection.canDomainEdit()) { protection.setDomainEdit(false); }
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
email | String[] | Kaldırılacak kullanıcıların e-posta adreslerinin dizisi. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
remove Target Audience(audienceId)
Belirtilen hedef kitleyi korumalı aralığın düzenleyeni olarak kaldırır.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
audience | String | Kaldırılacak hedef kitlenin kimliği. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Description(description)
Korunan aralığın veya sayfanın açıklamasını ayarlar.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets the sheet 'Sheet1' by its name. const sheet = ss.getSheetByName('Sheet1'); // Protects the sheet. const sampleProtectedSheet = sheet.protect(); // Sets the sheet description to 'Sheet1 is protected.' sampleProtectedSheet.setDescription('Sheet1 is protected'); // Gets the description of the protected sheet. const sampleProtectedSheetDescription = sampleProtectedSheet.getDescription(); // Logs the description of the protected sheet to the console. console.log(sampleProtectedSheetDescription);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
description | String | Korunan aralığın veya sayfanın açıklaması. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Domain Edit(editable)
E-tablonun sahibi olan alandaki tüm kullanıcıların korumalı aralığı veya sayfayı düzenleme iznine sahip olup olmadığını ayarlar. Açık düzenleme izni olan kullanıcıların, bu ayardan bağımsız olarak korunan alanı düzenleyebileceğini unutmayın. E-tablo bir Google Workspace alanına ait değilse (ör. gmail.com hesabına aitse) istisna oluşturur.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
editable | Boolean | E-tablonun sahibi olan alandaki tüm kullanıcıların korunan aralığı veya sayfayı düzenleme izni olmalıdırsa true, olmamalıysa false. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Named Range(namedRange)
Korumalı aralığı mevcut bir adlandırılmış aralıkla ilişkilendirir. Adlandırılmış aralık, mevcut korumalı aralıktan farklı bir alanı kapsıyorsa bu yöntem, korumayı adlandırılmış aralığı kapsayacak şekilde taşır. Adlandırılmış aralık, mevcut korumalı aralıkla aynı sayfada olmalıdır. Komut dosyalarının, korunan bir aralığı adlandırılmış bir aralıkla ilişkilendirmek için bu yöntemi açıkça çağırması gerektiğini unutmayın. Range.protect() yöntemini çağırarak Range yönteminden koruma oluşturmak (set yöntemi çağrılmadan) bu iki yöntemi ilişkilendirmek için yeterli değildir. Ancak, Google E-Tablolar kullanıcı arayüzünde adlandırılmış bir aralıktan korumalı aralık oluşturduğunuzda bu aralıklar otomatik olarak ilişkilendirilir.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Protects cells A1:D10 on Sheet1. const sheet = ss.getSheetByName('Sheet1'); const protectedRange = sheet.getRange('A1:D10').protect(); // Logs the current protected range, A1:D10. console.log(protectedRange.getRange().getA1Notation()); // Creates a named range for cells E1:J10 called 'NewRange.' const newRange = sheet.getRange('E1:J10'); ss.setNamedRange('NewRange', newRange); const namedRange = ss.getNamedRanges()[0]; // Updates the protected range to the named range, 'NewRange.' // This updates the protected range on Sheet1 from A1:D10 to E1:J10. protectedRange.setNamedRange(namedRange); // Logs the updated protected range to the console. console.log(protectedRange.getRange().getA1Notation());
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
named | Named | Korumalı aralıkla ilişkilendirilecek mevcut adlandırılmış aralık. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Range(range)
Korunan aralığı ayarlar. Belirtilen aralık, mevcut korunan aralıktan farklı bir alanı kapsıyorsa bu yöntem, korumayı yeni aralığı kapsayacak şekilde taşır.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Protects cells A1:D10 on Sheet1 of the spreadsheet. const sheet = ss.getSheetByName('Sheet1'); const protectedRange = sheet.getRange('A1:D10').protect(); // Logs the original protected range, A1:D10, to the console. console.log(protectedRange.getRange().getA1Notation()); // Gets the range E1:J10. const newRange = sheet.getRange('E1:J10'); // Updates the protected range to E1:J10. protectedRange.setRange(newRange); // Logs the updated protected range to the console. console.log(protectedRange.getRange().getA1Notation());
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
range | Range | Düzenlemelerden korunacak yeni aralık. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Range Name(rangeName)
Korumalı aralığı mevcut bir adlandırılmış aralıkla ilişkilendirir. Adlandırılmış aralık, mevcut korumalı aralıktan farklı bir alanı kapsıyorsa bu yöntem, korumayı adlandırılmış aralığı kapsayacak şekilde taşır. Adlandırılmış aralık, mevcut korumalı aralıkla aynı sayfada olmalıdır. Komut dosyalarının, korunan bir aralığı adlandırılmış bir aralıkla ilişkilendirmek için bu yöntemi açıkça çağırması gerektiğini unutmayın. Range.protect() yöntemini çağırarak Range yönteminden koruma oluşturmak (set yöntemi çağrılmadan) bu iki yöntemi ilişkilendirmek için yeterli değildir. Ancak, Google E-Tablolar kullanıcı arayüzünde adlandırılmış bir aralıktan korumalı aralık oluşturduğunuzda bu aralıklar otomatik olarak ilişkilendirilir.
// Protect a named range in a spreadsheet and log the name of the protected // range. const ss = SpreadsheetApp.getActive(); const range = ss.getRange('A1:B10'); const protection = range.protect(); ss.setNamedRange('Test', range); // Create a named range. protection.setRangeName( 'Test'); // Associate the protection with the named range. Logger.log( protection.getRangeName()); // Verify the name of the protected range.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
range | String | Korunacak adlandırılmış aralığın adı. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Unprotected Ranges(ranges)
Korumalı bir sayfadaki belirli aralık dizisinin korumasını kaldırır. Protection nesnesi, korumalı bir sayfa yerine korumalı bir aralığa karşılık geliyorsa veya aralıkların herhangi biri korumalı sayfada değilse istisna oluşturur. Korumasız aralıkları değiştirmek için yeni bir aralık dizisi ayarlayın. Sayfanın tamamını yeniden korumak için boş bir dizi ayarlayın.
// Protect the active sheet except B2:C5, then remove all other users from the // list of editors. const sheet = SpreadsheetApp.getActiveSheet(); const protection = sheet.protect().setDescription('Sample protected sheet'); const unprotected = sheet.getRange('B2:C5'); protection.setUnprotectedRanges([unprotected]); // Ensure the current user is an editor before removing others. Otherwise, if // the user's edit permission comes from a group, the script throws an exception // upon removing the group. const me = Session.getEffectiveUser(); protection.addEditor(me); protection.removeEditors(protection.getEditors()); if (protection.canDomainEdit()) { protection.setDomainEdit(false); }
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
ranges | Range[] | Korunan bir sayfada korumasız bırakılacak aralıklar dizisi. |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Warning Only(warningOnly)
Bu korumalı aralığın "uyarı tabanlı" koruma kullanıp kullanmadığını ayarlar. Uyarı tabanlı koruma, her kullanıcının alandaki verileri düzenleyebileceği anlamına gelir. Ancak düzenleme işlemi, kullanıcıdan düzenlemeyi onaylamasını isteyen bir uyarıyı tetikler. Varsayılan olarak, korumalı aralıklar veya sayfalar uyarı tabanlı değildir. Uyarı durumunu kontrol etmek için is simgesini kullanın.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets the sheet 'Sheet1' by its name. const sheet = ss.getSheetByName('Sheet1'); // Protects the sheet and sets the protection to warning-based. const sampleProtectedSheet = sheet.protect().setWarningOnly(true); // Logs whether the protected sheet is warning-based to the console. console.log(sampleProtectedSheet.isWarningOnly());
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
warning | Boolean |
Return
Protection: Zincirleme için koruma ayarlarını temsil eden nesne.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets