From 6239fe4e03c038118bf097714d6a98a99cac619e Mon Sep 17 00:00:00 2001 From: Tom Solodyna <6312338+tsolid@users.noreply.github.com> Date: Sat, 4 Jan 2020 09:37:49 -0500 Subject: [PATCH 1/2] Added ability to rotate to a new sheet each month --- Code.gs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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(); From 10e257c9e8626d7161bf4e55fc3ea451ed2d0acb Mon Sep 17 00:00:00 2001 From: Tom Solodyna <6312338+tsolid@users.noreply.github.com> Date: Sat, 4 Jan 2020 09:44:44 -0500 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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