-
Notifications
You must be signed in to change notification settings - Fork 0
/
script google.txt
40 lines (38 loc) · 1.48 KB
/
script google.txt
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
function doGet(e) {
Logger.log( JSON.stringify(e) ); // view parameters
if (e.parameter == 'undefined') {
}
else {
var sheet_id = 'id'; // Spreadsheet ID
var sheet = SpreadsheetApp.openById(sheet_id).getActiveSheet(); // get Active sheet
var newRow = sheet.getLastRow() + 1;
var rowData = [];
d=new Date();
rowData[0] = d; // Timestamp in column A
rowData[1] = d.toLocaleTimeString(); // Timestamp in column A
for (var param in e.parameter) {
Logger.log('In for loop, param=' + param);
var value = stripQuotes(e.parameter[param]);
Logger.log(param + ':' + e.parameter[param]);
switch (param) {
case 'value1': //Parameter 1, It has to be updated in Column in Sheets in the code, orderwise
rowData[2] = parseFloat(value); //Value in column A
break;
case 'value2': //Parameter 2, It has to be updated in Column in Sheets in the code, orderwise
rowData[3] = parseFloat(value); //Value in column B
break;
case 'value3': //Parameter 3, It has to be updated in Column in Sheets in the code, orderwise
rowData[4] = parseFloat(value); //Value in column C
break;
default:
}
}
var newRange = sheet.getRange(newRow, 1, 1, rowData.length);
newRange.setValues([rowData]);
}
// Return result of operation
return ContentService.createTextOutput("Recibido");
}
function stripQuotes( value ) {
return value.replace(/^["']|['"]$/g, "");
}