সুরক্ষিত রেঞ্জ এবং শীট অ্যাক্সেস ও পরিবর্তন করুন। একটি সুরক্ষিত রেঞ্জ সেলের একটি স্থির পরিসর বা একটি নামযুক্ত পরিসরকে সুরক্ষিত করতে পারে। একটি সুরক্ষিত শীটে অসুরক্ষিত অঞ্চল অন্তর্ভুক্ত থাকতে পারে। গুগল শীটসের পুরোনো সংস্করণ দিয়ে তৈরি স্প্রেডশীটগুলির জন্য, এর পরিবর্তে ক্লাস ব্যবহার করুন।PageProtection
বিদ্যমান সুরক্ষাগুলি পুনরুদ্ধার করতে, Sheet.getProtections(type) অথবা Spreadsheet.getProtections(type) ব্যবহার করুন।
// 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); }
পদ্ধতি
| পদ্ধতি | রিটার্ন টাইপ | সংক্ষিপ্ত বিবরণ |
|---|---|---|
add Editor(emailAddress) | Protection | প্রদত্ত ব্যবহারকারীকে সুরক্ষিত শীট বা রেঞ্জের সম্পাদকদের তালিকায় যুক্ত করে। |
add Editor(user) | Protection | প্রদত্ত ব্যবহারকারীকে সুরক্ষিত শীট বা রেঞ্জের সম্পাদকদের তালিকায় যুক্ত করে। |
add Editors(emailAddresses) | Protection | সুরক্ষিত শীট বা রেঞ্জের সম্পাদকদের তালিকায় প্রদত্ত ব্যবহারকারীদের অ্যারে যোগ করে। |
add Target Audience(audienceId) | Protection | নির্দিষ্ট লক্ষ্য দর্শকগোষ্ঠীকে সুরক্ষিত পরিসরের সম্পাদক হিসেবে যুক্ত করে। |
can Domain Edit() | Boolean | স্প্রেডশিটটির মালিক ডোমেইনের সকল ব্যবহারকারীর সুরক্ষিত রেঞ্জ বা শীটটি সম্পাদনা করার অনুমতি আছে কিনা তা নির্ধারণ করে। |
can Edit() | Boolean | ব্যবহারকারীর সুরক্ষিত রেঞ্জ বা শীট সম্পাদনা করার অনুমতি আছে কিনা তা নির্ধারণ করে। |
get Description() | String | সংরক্ষিত পরিসর বা শীটের বিবরণ পাওয়া যায়। |
get Editors() | User[] | সুরক্ষিত রেঞ্জ বা শীটের জন্য সম্পাদকদের তালিকা পাওয়া যায়। |
get Protection Type() | Protection Type | সুরক্ষিত এলাকার ধরনটি পাওয়া যায়, যা হয় RANGE ) অথবা SHEET )। |
get Range() | Range | যে পরিসরটি সুরক্ষিত করা হচ্ছে, তা পাওয়া যায়। |
get Range Name() | String|null | যদি সুরক্ষিত রেঞ্জটি কোনো নামযুক্ত রেঞ্জের সাথে যুক্ত থাকে, তবে তার নামটি পাওয়া যায়। |
get Target Audiences() | Target Audience[] | সেইসব টার্গেট অডিয়েন্সের আইডিগুলো ফেরত দেয় যারা সুরক্ষিত পরিসরটি সম্পাদনা করতে পারে। |
get Unprotected Ranges() | Range[] | একটি সুরক্ষিত শীটের মধ্যে থাকা অসুরক্ষিত রেঞ্জগুলির একটি অ্যারে পায়। |
is Warning Only() | Boolean | সুরক্ষিত এলাকাটি 'সতর্কীকরণ-ভিত্তিক' সুরক্ষা ব্যবহার করছে কিনা তা নির্ধারণ করে। |
remove() | void | রেঞ্জ বা শিটকে অরক্ষিত করে। |
remove Editor(emailAddress) | Protection | সুরক্ষিত শীট বা রেঞ্জের সম্পাদকদের তালিকা থেকে প্রদত্ত ব্যবহারকারীকে সরিয়ে দেয়। |
remove Editor(user) | Protection | সুরক্ষিত শীট বা রেঞ্জের সম্পাদকদের তালিকা থেকে প্রদত্ত ব্যবহারকারীকে সরিয়ে দেয়। |
remove Editors(emailAddresses) | Protection | সুরক্ষিত শীট বা রেঞ্জের সম্পাদকদের তালিকা থেকে প্রদত্ত ব্যবহারকারীদের অ্যারেটি সরিয়ে দেয়। |
remove Target Audience(audienceId) | Protection | সুরক্ষিত পরিসরের সম্পাদক হিসেবে নির্দিষ্ট লক্ষ্য দর্শকগোষ্ঠীকে অপসারণ করে। |
set Description(description) | Protection | সুরক্ষিত পরিসর বা শীটের বিবরণ নির্ধারণ করে। |
set Domain Edit(editable) | Protection | স্প্রেডশিটটির মালিক ডোমেইনের সকল ব্যবহারকারীর সুরক্ষিত রেঞ্জ বা শীটটি সম্পাদনা করার অনুমতি থাকবে কিনা তা নির্ধারণ করে। |
set Named Range(namedRange) | Protection | সুরক্ষিত পরিসরটিকে একটি বিদ্যমান নামযুক্ত পরিসরের সাথে সংযুক্ত করে। |
set Range(range) | Protection | সুরক্ষিত পরিসরটি সমন্বয় করে। |
set Range Name(rangeName) | Protection | সুরক্ষিত পরিসরটিকে একটি বিদ্যমান নামযুক্ত পরিসরের সাথে সংযুক্ত করে। |
set Unprotected Ranges(ranges) | Protection | একটি সুরক্ষিত শীটের মধ্যে থাকা রেঞ্জগুলির প্রদত্ত অ্যারেটিকে অসুরক্ষিত করে। |
set Warning Only(warningOnly) | Protection | এই সুরক্ষিত পরিসরটি "সতর্কতা-ভিত্তিক" সুরক্ষা ব্যবহার করবে কি না, তা নির্ধারণ করে। |
বিস্তারিত ডকুমেন্টেশন
addEditor(emailAddress)
প্রদত্ত ব্যবহারকারীকে সুরক্ষিত শীট বা রেঞ্জের সম্পাদকদের তালিকায় যুক্ত করে। এই পদ্ধতিটি স্বয়ংক্রিয়ভাবে ব্যবহারকারীকে স্প্রেডশীটটি সম্পাদনা করার অনুমতি দেয় না; অতিরিক্তভাবে তা করার জন্য, Spreadsheet.addEditor(emailAddress) কল করুন।
// 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()); }
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
email Address | String | যোগ করার জন্য ব্যবহারকারীর ইমেল ঠিকানা। |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
addEditor(user)
প্রদত্ত ব্যবহারকারীকে সুরক্ষিত শীট বা রেঞ্জের সম্পাদকদের তালিকায় যুক্ত করে। এই পদ্ধতিটি স্বয়ংক্রিয়ভাবে ব্যবহারকারীকে স্প্রেডশীটটি সম্পাদনা করার অনুমতি দেয় না; অতিরিক্তভাবে তা করার জন্য, Spreadsheet.addEditor(user) কল করুন।
// 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()); }
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
user | User | যোগ করার জন্য ব্যবহারকারীর একটি উপস্থাপনা। |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
addEditors(emailAddresses)
সুরক্ষিত শীট বা রেঞ্জের সম্পাদকদের তালিকায় প্রদত্ত ব্যবহারকারীদের অ্যারে যোগ করে। এই পদ্ধতিটি স্বয়ংক্রিয়ভাবে ব্যবহারকারীদের স্প্রেডশীটটি সম্পাদনা করার অনুমতি দেয় না; অতিরিক্তভাবে তা করার জন্য, Spreadsheet.addEditors(emailAddresses) কল করুন।
// 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()); }
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
email Addresses | String[] | যোগ করার জন্য ব্যবহারকারীদের ইমেল ঠিকানাগুলোর একটি অ্যারে। |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
addTargetAudience(audienceId)
নির্দিষ্ট লক্ষ্য দর্শকগোষ্ঠীকে সুরক্ষিত পরিসরের সম্পাদক হিসেবে যুক্ত করে।
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
audience Id | String | যোগ করার জন্য লক্ষ্য দর্শকদের আইডি। |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
canDomainEdit()
স্প্রেডশিটটির মালিক ডোমেইনের সকল ব্যবহারকারীর সুরক্ষিত রেঞ্জ বা শীটটি সম্পাদনা করার অনুমতি আছে কিনা তা নির্ধারণ করে। যদি ব্যবহারকারীর সুরক্ষিত রেঞ্জ বা শীটটি সম্পাদনা করার অনুমতি না থাকে, তবে একটি ব্যতিক্রমী ত্রুটি (exception) প্রদর্শন করে।
// 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());
ফেরত
Boolean — যদি স্প্রেডশিটটির মালিক ডোমেইনের সকল ব্যবহারকারীর সুরক্ষিত রেঞ্জ বা শীটটি সম্পাদনা করার অনুমতি থাকে তবে true ; না থাকলে false ।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
canEdit()
ব্যবহারকারীর সুরক্ষিত রেঞ্জ বা শীট সম্পাদনা করার অনুমতি আছে কিনা তা নির্ধারণ করে। স্প্রেডশীটের মালিক সর্বদা সুরক্ষিত রেঞ্জ এবং শীট সম্পাদনা করতে পারেন।
// 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(); } }
ফেরত
Boolean — যদি ব্যবহারকারীর সুরক্ষিত রেঞ্জ বা শীট সম্পাদনা করার অনুমতি থাকে তবে true ; না থাকলে false ।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
getDescription()
সুরক্ষিত রেঞ্জ বা শীটের বিবরণ পাওয়া যায়। যদি কোনো বিবরণ সেট করা না থাকে, তাহলে এই মেথডটি একটি খালি স্ট্রিং রিটার্ন করে।
// 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);
ফেরত
String — সুরক্ষিত রেঞ্জ বা শীটের বিবরণ, অথবা কোনো বিবরণ সেট করা না থাকলে একটি খালি স্ট্রিং।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
getEditors()
সুরক্ষিত রেঞ্জ বা শীটের সম্পাদকদের তালিকা সংগ্রহ করে। ব্যবহারকারীর সুরক্ষিত রেঞ্জ বা শীটটি সম্পাদনা করার অনুমতি না থাকলে একটি ব্যতিক্রমী ত্রুটি (exception) প্রদর্শন করে।
// 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); }
ফেরত
User[] — সুরক্ষিত পরিসর বা শীট সম্পাদনা করার অনুমতিপ্রাপ্ত ব্যবহারকারীদের একটি অ্যারে
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
getProtectionType()
সুরক্ষিত এলাকার ধরনটি পাওয়া যায়, যা হয় RANGE ) অথবা SHEET )।
// 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());
ফেরত
ProtectionType — সুরক্ষিত এলাকার ধরণ, হয় RANGE ) অথবা SHEET )।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
getRange()
যে রেঞ্জটি সুরক্ষিত করা হচ্ছে, তা পাওয়া যায়। যদি সুরক্ষাটি কোনো রেঞ্জের পরিবর্তে শীটের উপর প্রযোজ্য হয়, তাহলে এই মেথডটি এমন একটি রেঞ্জ রিটার্ন করে যা সম্পূর্ণ শীট জুড়ে বিস্তৃত থাকে।
// 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());
ফেরত
Range — যে পরিসরটি সুরক্ষিত করা হচ্ছে।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
getRangeName()
যদি সুরক্ষিত রেঞ্জটি কোনো নেমড রেঞ্জের সাথে যুক্ত থাকে, তবে এর নামটি পাওয়া যায়। যদি সুরক্ষাটি কোনো নেমড রেঞ্জের সাথে যুক্ত না থাকে, তবে null রিটার্ন করে। মনে রাখবেন যে, একটি সুরক্ষিত রেঞ্জকে একটি নেমড রেঞ্জের সাথে যুক্ত করার জন্য স্ক্রিপ্টে অবশ্যই স্পষ্টভাবে setRangeName(rangeName) কল করতে হবে; setRangeName(rangeName) কল না করে, শুধুমাত্র Range.protect() কল করে এমন একটি Range থেকে সুরক্ষা তৈরি করা, যা কিনা একটি নেমড রেঞ্জ, তাদের যুক্ত করার জন্য যথেষ্ট নয়। তবে, গুগল শিটস UI-তে একটি নেমড রেঞ্জ থেকে একটি সুরক্ষিত রেঞ্জ তৈরি করলে, তারা স্বয়ংক্রিয়ভাবে যুক্ত হয়ে যায়।
// 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.
ফেরত
String|null — সুরক্ষিত নেমড রেঞ্জের নাম, অথবা null যদি সুরক্ষিত রেঞ্জটি কোনো নেমড রেঞ্জের সাথে যুক্ত না থাকে।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
getTargetAudiences()
সেইসব টার্গেট অডিয়েন্সের আইডিগুলো ফেরত দেয় যারা সুরক্ষিত পরিসরটি সম্পাদনা করতে পারে।
ফেরত
TargetAudience[] — টার্গেট অডিয়েন্সগুলোর আইডি-র একটি অ্যারে।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
getUnprotectedRanges()
একটি সুরক্ষিত শীটের মধ্যে থাকা অসুরক্ষিত রেঞ্জগুলির একটি অ্যারে প্রদান করে। যদি Protection অবজেক্টটি কোনো সুরক্ষিত শীটের পরিবর্তে একটি সুরক্ষিত রেঞ্জকে নির্দেশ করে, তবে এই মেথডটি একটি খালি অ্যারে রিটার্ন করে। অসুরক্ষিত রেঞ্জগুলি পরিবর্তন করতে, setUnprotectedRanges(ranges) ব্যবহার করে রেঞ্জগুলির একটি নতুন অ্যারে সেট করুন; সম্পূর্ণ শীটটিকে পুনরায় সুরক্ষিত করতে, একটি খালি অ্যারে সেট করুন।
// 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);
ফেরত
Range[] — একটি সুরক্ষিত শীটের মধ্যে অবস্থিত অসুরক্ষিত রেঞ্জগুলির একটি অ্যারে
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
isWarningOnly()
সুরক্ষিত এলাকাটি "সতর্কতা-ভিত্তিক" সুরক্ষা ব্যবহার করছে কিনা তা নির্ধারণ করে। সতর্কতা-ভিত্তিক সুরক্ষার অর্থ হলো, প্রত্যেক ব্যবহারকারী ঐ এলাকার ডেটা সম্পাদনা করতে পারে, তবে সম্পাদনা করার সময় একটি সতর্কতা বার্তা প্রদর্শিত হয় যা ব্যবহারকারীকে সম্পাদনাটি নিশ্চিত করতে বলে। ডিফল্টরূপে, সুরক্ষিত রেঞ্জ বা শীটগুলো সতর্কতা-ভিত্তিক হয় না। সতর্কতা অবস্থায় পরিবর্তন করতে, setWarningOnly(warningOnly) ব্যবহার করুন।
// 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);
ফেরত
Boolean — যদি সুরক্ষিত রেঞ্জ বা শীটটি শুধুমাত্র সতর্কীকরণ-ভিত্তিক সুরক্ষা ব্যবহার করে, তবে true ।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
remove()
রেঞ্জ বা শিটকে অরক্ষিত করে।
// 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(); }
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
removeEditor(emailAddress)
সুরক্ষিত শীট বা রেঞ্জের সম্পাদকদের তালিকা থেকে প্রদত্ত ব্যবহারকারীকে সরিয়ে দেয়। উল্লেখ্য যে, যদি ব্যবহারকারী এমন কোনো গুগল গ্রুপের সদস্য হন যার সম্পাদনার অনুমতি আছে, অথবা যদি ডোমেইনের সকল ব্যবহারকারীর সম্পাদনার অনুমতি থাকে, তাহলেও ব্যবহারকারী সুরক্ষিত এলাকাটি সম্পাদনা করতে পারবেন। স্প্রেডশীটের মালিক বা বর্তমান ব্যবহারকারী কাউকেই সরানো যাবে না।
// 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()); }
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
email Address | String | অপসারণ করার জন্য ব্যবহারকারীর ইমেইল ঠিকানা। |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
removeEditor(user)
সুরক্ষিত শীট বা রেঞ্জের সম্পাদকদের তালিকা থেকে প্রদত্ত ব্যবহারকারীকে সরিয়ে দেয়। উল্লেখ্য যে, যদি ব্যবহারকারী এমন কোনো গুগল গ্রুপের সদস্য হন যার সম্পাদনার অনুমতি আছে, অথবা যদি ডোমেইনের সকল ব্যবহারকারীর সম্পাদনার অনুমতি থাকে, তাহলেও ব্যবহারকারী সুরক্ষিত এলাকাটি সম্পাদনা করতে পারবেন। স্প্রেডশীটের মালিক বা বর্তমান ব্যবহারকারী কাউকেই সরানো যাবে না।
// 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()); }
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
user | User | ব্যবহারকারীকে অপসারণ করার একটি উপস্থাপনা। |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
removeEditors(emailAddresses)
সুরক্ষিত শীট বা রেঞ্জের সম্পাদকদের তালিকা থেকে প্রদত্ত ব্যবহারকারীদের সরিয়ে দেয়। উল্লেখ্য যে, যদি ব্যবহারকারীদের মধ্যে কেউ সম্পাদনার অনুমতিপ্রাপ্ত কোনো গুগল গ্রুপের সদস্য হন, অথবা যদি ডোমেইনের সকল ব্যবহারকারীর সম্পাদনার অনুমতি থাকে, তাহলেও সেই ব্যবহারকারীরা সুরক্ষিত এলাকাটি সম্পাদনা করতে পারবেন। স্প্রেডশীটের মালিক বা বর্তমান ব্যবহারকারী কাউকেই সরানো যাবে না।
// 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); }
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
email Addresses | String[] | অপসারণ করার জন্য ব্যবহারকারীদের ইমেল ঠিকানাগুলোর একটি তালিকা। |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
removeTargetAudience(audienceId)
সুরক্ষিত পরিসরের সম্পাদক হিসেবে নির্দিষ্ট লক্ষ্য দর্শকগোষ্ঠীকে অপসারণ করে।
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
audience Id | String | অপসারণ করার জন্য লক্ষ্য দর্শকদের আইডি। |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setDescription(description)
সুরক্ষিত পরিসর বা শীটের বিবরণ নির্ধারণ করে।
// 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);
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
description | String | সংরক্ষিত পরিসর বা শীটের বিবরণ। |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setDomainEdit(editable)
স্প্রেডশীটটির মালিক ডোমেইনের সকল ব্যবহারকারী সুরক্ষিত অংশ বা শীটটি সম্পাদনা করার অনুমতি পাবে কিনা, তা এটি নির্ধারণ করে। উল্লেখ্য যে, যে সকল ব্যবহারকারীর সুস্পষ্ট সম্পাদনার অনুমতি রয়েছে, তারা এই সেটিং নির্বিশেষে সুরক্ষিত এলাকাটি সম্পাদনা করতে পারবেন। যদি স্প্রেডশীটটি কোনো গুগল ওয়ার্কস্পেস ডোমেইনের অন্তর্ভুক্ত না হয় (অর্থাৎ, যদি এটি কোনো gmail.com অ্যাকাউন্টের মালিকানাধীন হয়), তবে একটি ব্যতিক্রমী ত্রুটি (exception) দেখানো হবে।
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
editable | Boolean | যদি স্প্রেডশিটটির মালিক ডোমেইনের সকল ব্যবহারকারীর সুরক্ষিত রেঞ্জ বা শীটটি সম্পাদনা করার অনুমতি থাকা উচিত হয়, তবে true ; অন্যথায় false । |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setNamedRange(namedRange)
একটি সুরক্ষিত রেঞ্জকে বিদ্যমান কোনো নেমড রেঞ্জের সাথে যুক্ত করে। যদি নেমড রেঞ্জটি বর্তমান সুরক্ষিত রেঞ্জ থেকে ভিন্ন কোনো এলাকা জুড়ে থাকে, তবে এই পদ্ধতিটি সুরক্ষাটিকে সেই নেমড রেঞ্জের আওতায় নিয়ে আসে। নেমড রেঞ্জটি অবশ্যই বর্তমান সুরক্ষিত রেঞ্জের সাথে একই শীটে থাকতে হবে। মনে রাখবেন, একটি সুরক্ষিত রেঞ্জকে একটি নেমড রেঞ্জের সাথে যুক্ত করার জন্য স্ক্রিপ্টগুলোকে অবশ্যই এই পদ্ধতিটি স্পষ্টভাবে কল করতে হবে; setRangeName(rangeName) কল না করে, শুধুমাত্র Range.protect() কল করে এমন একটি Range থেকে সুরক্ষা তৈরি করা, যা কিনা একটি নেমড রেঞ্জ, তাদেরকে যুক্ত করার জন্য যথেষ্ট নয়। তবে, গুগল শীটস UI-তে একটি নেমড রেঞ্জ থেকে একটি সুরক্ষিত রেঞ্জ তৈরি করলে, তারা স্বয়ংক্রিয়ভাবে যুক্ত হয়ে যায়।
// 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());
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
named Range | Named Range | বিদ্যমান নামযুক্ত পরিসরটিকে সুরক্ষিত পরিসরের সাথে সংযুক্ত করতে হবে। |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setRange(range)
সুরক্ষিত পরিসরকে সমন্বয় করে। যদি প্রদত্ত পরিসরটি বর্তমান সুরক্ষিত পরিসর থেকে ভিন্ন কোনো এলাকা জুড়ে থাকে, তবে এই পদ্ধতিটি সুরক্ষাকে নতুন পরিসরটিতে স্থানান্তরিত করে।
// 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());
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
range | Range | সম্পাদনা থেকে সুরক্ষার জন্য নতুন পরিসর। |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setRangeName(rangeName)
একটি সুরক্ষিত রেঞ্জকে বিদ্যমান কোনো নেমড রেঞ্জের সাথে যুক্ত করে। যদি নেমড রেঞ্জটি বর্তমান সুরক্ষিত রেঞ্জ থেকে ভিন্ন কোনো এলাকা জুড়ে থাকে, তবে এই পদ্ধতিটি সুরক্ষাটিকে সেই নেমড রেঞ্জের আওতায় নিয়ে আসে। নেমড রেঞ্জটি অবশ্যই বর্তমান সুরক্ষিত রেঞ্জের সাথে একই শীটে থাকতে হবে। মনে রাখবেন, একটি সুরক্ষিত রেঞ্জকে একটি নেমড রেঞ্জের সাথে যুক্ত করার জন্য স্ক্রিপ্টগুলোকে অবশ্যই এই পদ্ধতিটি স্পষ্টভাবে কল করতে হবে; setRangeName(rangeName) কল না করে, শুধুমাত্র Range.protect() কল করে এমন একটি Range থেকে সুরক্ষা তৈরি করা, যা কিনা একটি নেমড রেঞ্জ, তাদেরকে যুক্ত করার জন্য যথেষ্ট নয়। তবে, গুগল শীটস UI-তে একটি নেমড রেঞ্জ থেকে একটি সুরক্ষিত রেঞ্জ তৈরি করলে, তারা স্বয়ংক্রিয়ভাবে যুক্ত হয়ে যায়।
// 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.
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
range Name | String | সুরক্ষিত করা হবে এমন নামযুক্ত পরিসরের নাম। |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setUnprotectedRanges(ranges)
একটি সুরক্ষিত শীটের মধ্যে থাকা রেঞ্জগুলির প্রদত্ত অ্যারেটিকে অসুরক্ষিত করে। যদি Protection অবজেক্টটি কোনো সুরক্ষিত শীটের পরিবর্তে একটি সুরক্ষিত রেঞ্জের সাথে সম্পর্কিত হয় অথবা যদি রেঞ্জগুলির কোনোটি সুরক্ষিত শীটে না থাকে, তাহলে একটি এক্সেপশন থ্রো করা হয়। অসুরক্ষিত রেঞ্জগুলি পরিবর্তন করতে, রেঞ্জগুলির একটি নতুন অ্যারে সেট করুন; সম্পূর্ণ শীটটিকে পুনরায় সুরক্ষিত করতে, একটি খালি অ্যারে সেট করুন।
// 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); }
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
ranges | Range[] | একটি সুরক্ষিত শীটের মধ্যে অরক্ষিত রাখার জন্য পরিসরের বিন্যাস। |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
setWarningOnly(warningOnly)
এই সুরক্ষিত রেঞ্জটি "সতর্কতা-ভিত্তিক" সুরক্ষা ব্যবহার করবে কি না তা নির্ধারণ করে। সতর্কতা-ভিত্তিক সুরক্ষার অর্থ হলো, প্রত্যেক ব্যবহারকারী ঐ এলাকার ডেটা সম্পাদনা করতে পারে, তবে সম্পাদনা করার সময় একটি সতর্কতা বার্তা প্রদর্শিত হয় যা ব্যবহারকারীকে সম্পাদনাটি নিশ্চিত করতে বলে। ডিফল্টরূপে, সুরক্ষিত রেঞ্জ বা শীটগুলো সতর্কতা-ভিত্তিক হয় না। সতর্কতার অবস্থা পরীক্ষা করতে, isWarningOnly() ব্যবহার করুন।
// 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());
প্যারামিটার
| নাম | প্রকার | বর্ণনা |
|---|---|---|
warning Only | Boolean |
ফেরত
Protection — চেইনিংয়ের জন্য সুরক্ষা সেটিংসের প্রতিনিধিত্বকারী অবজেক্ট।
অনুমোদন
যে স্ক্রিপ্টগুলো এই পদ্ধতি ব্যবহার করে, সেগুলোর জন্য নিম্নলিখিত এক বা একাধিক স্কোপের মাধ্যমে অনুমোদনের প্রয়োজন হয়:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets