How to protect sheet timely using appscript in hindi


दोस्तों गूगल सीट में किस तरीके से प्रोटेक्शन लगाया जाता है | उसके बारे में हम सभी लोग जानते हैं | आज हम इस आर्टिकल में भी प्रोटेक्शन की ही बात करेंगे | लेकिन यह प्रोटेक्शन अन्य प्रोटेक्शन से थोड़ा सा डिफरेंट होगा | और यह डिफरेंट क्या होगा कि इसमें हम सीखेंगे कि हम टाइमली (How to protect sheet timely using appscript in hindi) गूगल सीट की डाटा को कैसे प्रोटेक्ट कर सकते हैं |

file for practice

यह भी पढ़ें:-protect cell after edit


>
  
    function lockingUnlockingSheet() {
      let sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet2");
      let lockingHour = 21;
      let unlockingHour = 6;
      let currentHour = new Date().getHours();
      if (lockingHour >= currentHour && unlockingHour < currentHour) {
        let protection = sheet.protect().setDescription("Protect Sheet")
        protection.removeEditors(protection.getEditors());
      } else {
        let protections = sheet.getProtections(SpreadsheetApp.ProtectionType.SHEET);
        for (let i = 0; i < protections.length; i++) {
          protections[i].remove();
        }
      }
    }