This apps script code I have previously used to create a new sheet(tab/grid) in an existing spreadsheet:
//insert a new grid, with name, to a specified sheet
function insertGridToSheet(name,sheetID) {
var ss = SpreadsheetApp.openById(sheetID);
var shs = ss.getSheets();
ss.insertSheet(name,shs.length + 1);
return ContentService.createTextOutput(name + ' added');
}
This function is called as follows:
//add new grid to sheet
if ( e.parameter.func == "newGridForSheet" ) {
return insertGridToSheet(e.parameter.name,e.parameter.sheetID);
}
you will need to supply:
- The "func" selector
- The spreadsheet ID
- The name for the new sheet(tab/grid)
The new sheet(tab/grid) is placed as the last sheet(tab/grid)