-
Notifications
You must be signed in to change notification settings - Fork 0
/
Esp8266_SpredSheet.gs
43 lines (23 loc) · 1.26 KB
/
Esp8266_SpredSheet.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var ss = SpreadsheetApp.openById('1YjlEimTa6MOZJPlojDc7fKnFbjzVC11Wsaj_IcNYx7g');
var sheet = ss.getSheetByName('Data');
var menu = ss.getSheetByName('Menu');
function doGet(e){
var tag = e.parameters.tag;
var val = e.parameter.value;
var read = e.parameter.read;
if (read !== undefined){
return ContentService.createTextOutput(menu.getRange('C2').getValue());
}
//-------------------------------------------------------------------
var row = sheet.getLastRow() + 1;
var now = Utilities.formatDate(new Date(), "EST", "dd/mm/yy'*****'hh:mm a");
var range = sheet.getRange("C" + row); var retval = range.setValue(val).getValue();
sheet.getRange("A" + row).setValue(row -1).getValue();
sheet.getRange("B" + row).setValue(now).getValue();
sheet.getRange("D" + row).setValue(tag).getValue();
//----------------------------------------------------------------
if (retval == e.parameter.value)
return ContentService.createTextOutput("Successfully wrote: " + e.parameter.value + "\ninto spreadsheet.");
else
return ContentService.createTextOutput("Unable to write into spreadsheet.\nCheck authentication and make sure the cursor is not on cell 'A2'." + retval + ' ' + e.parameter.value);
}