-
Notifications
You must be signed in to change notification settings - Fork 0
/
Helpers.gs
48 lines (42 loc) · 1.26 KB
/
Helpers.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
41
42
43
44
45
46
47
48
function getColValuesByName_(colName, data) {
let col = data[0].indexOf(colName);
let colValues = [];
if (col != -1) {
for (let i = 1; i < data.length; i++) {
if (data[i][col]) colValues.push(data[i][col]);
}
}
return colValues;
}
function getMatchedStr_(str, regExp) {
const strMatches = str.match(regExp);
if (strMatches && strMatches.length > 0) {
return strMatches[0].trim();
} else {
return "";
}
}
function toTitleCase_(str) {
return str.replace(
/\w\S*/g,
function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
}
);
}
function beautifyDataSheet_(dataSheet) {
dataSheet.setFrozenRows(1);
dataSheet.setFrozenColumns(1);
dataSheet.hideColumn(dataSheet.getRange("B1"));
let debitAmountFormattingRule = SpreadsheetApp.newConditionalFormatRule()
.setGradientMaxpoint("#E87674")
.setGradientMinpoint("#FFE0E1")
.setRanges([dataSheet.getRange("E1:E")])
.build();
let creditAmountFormattingRule = SpreadsheetApp.newConditionalFormatRule()
.setGradientMaxpoint("#A5E830")
.setGradientMinpoint("#E7FFE7")
.setRanges([dataSheet.getRange("F1:F")])
.build();
dataSheet.setConditionalFormatRules([debitAmountFormattingRule, creditAmountFormattingRule]);
}