Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down