diff --git a/Code.gs b/Code.gs index b29db26..84e3aac 100644 --- a/Code.gs +++ b/Code.gs @@ -3,7 +3,18 @@ function doGet(request) { if(request != null) { var ss = SpreadsheetApp.openById("REPLACE ME WITH SPREADSHEET ID"); - var sheet = ss.getSheetByName("Sheet1"); + + // rotate to new sheet each month + var monthSheetName = Utilities.formatDate(new Date(), "GMT+5", "yyyy-MM") + var sheet = ss.getSheetByName(monthSheetName); + if (!sheet) { + ss.insertSheet(monthSheetName); + sheet = ss.getSheetByName(monthSheetName); + initRow = new Array(1); + initRow[0]="Time"; + sheet.appendRow(initRow); + } + var firstRowRange = sheet.getRange(1, 1, 1, sheet.getLastColumn()); var sheetHeaders=firstRowRange.getValues(); diff --git a/README.md b/README.md index b0c7f83..adfb40d 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ 3. On line 4, Replace "REPLACE ME WITH SPREADSHEET ID" with sheet id from step 3 ![alt tag](img/stgsl6.png) - 4. If you changed the name of the sheet (the name in the tab at the bottom of the spreadsheet, not the name of the file), update it on line 5. (defaults to "Sheet1"). + 4. The script will create a sheet per month in the format YYYY-mm (eg: 2020-01). 6. Deploy helper script as webapp 1. Deploy webapp: Click Publish -> Deploy as web app