简体   繁体   中英

Google Sheets multiple passwords

I have the following appscript in my google sheets which asks user to input the password to access the file.

function openSheets(){
  SpreadsheetApp.getActive().getActiveSheet().hideRows(3, 31);
  hideAllSheetsExcept('Sheet1')
}

function hideAllSheetsExcept(sheetName) {

  var sheets=SpreadsheetApp.getActiveSpreadsheet().getSheets();
  for(var i =0;i<sheets.length;i++){
    Logger.log(i);
    if(sheets[i].getName()!=sheetName){
      sheets[i].hideSheet();
    }
  }
  var quest="";
  while (quest!='123'){
    quest = Browser.inputBox("Enter password");
  }
  SpreadsheetApp.getActive().getActiveSheet().showRows(3, 31);
  SpreadsheetApp.getActive().getRange('B5').activate();
}

I want to share this with my friends like 3 of them. But I want to give them each a different password to access this. How can I change this code to accept multiple passwords?

  const pw = ['123', '456', '789'];
  while (!pw.includes(quest)){
    quest = Browser.inputBox("Enter password");
  }

Reference:

Array.prototype.includes()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM