/ Published in: C++
Delete all sheets in a Google Drive Spreadsheet by name/active spreadsheet
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Delete all sheets in Google Drive Spreadsheet by name. // Author : Selva Kumar // Blog : slvakumr.com // Date : 30 October 2014 function DeleteAllSheetsInSpreadSheet(name){ var files = DriveApp.getFilesByType(MimeType.GOOGLE_SHEETS) while (files.hasNext()) { var file = files.next(); if (file.getName() == name) { var url = file.getUrl(); var sheet = SpreadsheetApp.openByUrl(url); SpreadsheetApp.setActiveSpreadsheet(sheet); DeleteAllSheets(); } } } // Delete all sheets in active Google Drive Spreadsheet. // Author : Selva Kumar // Blog : slvakumr.com // Date : 30 October 2014 function DeleteAllSheets(){ var activeSpreadSheet = SpreadsheetApp.getActiveSpreadsheet(); var sheets = activeSpreadSheet.getSheets(); for(var i = 0; i < sheets.length-1; i++) { activeSpreadSheet.deleteSheet(sheets[i]) } }