-
Notifications
You must be signed in to change notification settings - Fork 0
/
getOptionsData.gs
30 lines (25 loc) · 973 Bytes
/
getOptionsData.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
var OPTIONS = {};
function getOptionsData(reportType) {
var _ss = SpreadsheetApp.getActiveSpreadsheet();
var optionsSheet = _ss.setActiveSheet(getOptionsSheet());
var data = optionsSheet.getRange(1, 1, optionsSheet.getLastRow(), optionsSheet.getLastColumn()).getValues();
data.forEach(function(row) {
var key = row.shift();
row = row.filter(function(a) {
if (a === 0) return true;
return a
});
OPTIONS[key] = row.length > 1 ? row : row[0];
});
OPTIONS.quantity = 20;
OPTIONS.startDate.setHours(OPTIONS.startDate.getHours() - 1 * OPTIONS.startDate.getTimezoneOffset() / 60);
OPTIONS.finalDate.setHours(OPTIONS.finalDate.getHours() - 1 * OPTIONS.finalDate.getTimezoneOffset() / 60);
}
function getOptionsSheet() {
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
for (var i = 0; i < sheets.length; i++) {
if (sheets[i].getName().toLowerCase() === 'options')
return sheets[i];
}
return null;
}