๐Ÿ’พapp.sheetByName()

GAS โŸฉ app โŸฉ methods โŸฉ sheetByName()

  // ๐Ÿ”ธ app.sheetByName()
  sheetByName(name) {

    const ss = app.spreadsheet;
    let sheet = ss.getSheetByName(name);

    // if no such sheet, append a new one.
    if(sheet === null){ 
      let i = ss.getNumSheets();          // ็›ฎๅ‰็š„ๆœ‰ๅนพ้ 
      sheet = ss.insertSheet(name, i);    // ๆ’ๅ…ฅๆœ€ๅพŒ้ข (โญ๏ธ will activate automatically)
    }

    sheet.activate();                     // โญ๏ธ activate before returning        
    sheet.__proto__ = app.sheetPrototype; // โญ๏ธ extend sheet 
    return sheet;
  },

Last updated