-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcode.gs.js
More file actions
34 lines (27 loc) · 961 Bytes
/
Copy pathcode.gs.js
File metadata and controls
34 lines (27 loc) · 961 Bytes
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
function doGet(e) {
return HtmlService.createTemplateFromFile("index.html")
.evaluate()
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
// get the chart data to pass through to front-end
function getChartData() {
var ss = SpreadsheetApp.openById("XXXXXXXXXXXXXX"); // Your spreadsheet ID goes here
Logger.log(ss);
//var sheet = ss.getActiveSheet();
var sheet = ss.getSheetByName("Cloud");
var headings = sheet.getRange(3,1,1,sheet.getLastColumn()).getValues()[0].map(function(heading) {
return heading.toLowerCase();
});
Logger.log(headings);
var values = sheet.getRange(4, 1, sheet.getLastRow()-3, sheet.getLastColumn()).getValues();
var data = [];
for (var i=0; i < values.length; i++) {
var obj = {};
for (var j = 0; j < values[i].length; j++) {
obj[headings[j]] = values[i][j];
}
data.push(obj);
}
return data;
}