Get a list of all the sheet tab names from a Google spreadsheet and put the names into another spreadsheet

Viewed 3731

I have a google spreadsheet that contains around 50 to 60 sheets. I am trying to get the names of all those sheets, and put them into another spreadsheet.

So far I have written the following code

function myfunction(){
  var ss = SpreadsheetApp.openById("abck12345");
  var sheetCount = ss.getSheets().length;
  var  i=0;

  var sheetlist;

  while(i<sheetCount){
    sheetlist = ss.getSheets()[i];
    Logger.log(sheetlist);
  }

}

While executing this i am getting an error "Exceeded maximum execution time"

2 Answers
Related