-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCryptoWalletsReport.gs
40 lines (31 loc) · 1.22 KB
/
CryptoWalletsReport.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
/**
* Creates the crypto wallets report if it doesn't already exist.
* Updated the sheet if the version is not the current version.
* No data is writen to this sheet.
* It contains formulas that pull data from other sheets.
*/
CryptoTracker.prototype.cryptoWalletsReport = function () {
const version = '1';
const sheetName = this.cryptoWalletsReportName;
let ss = SpreadsheetApp.getActive();
let sheet = ss.getSheetByName(sheetName);
if (sheet) {
if (this.getSheetVersion(sheet) === version) {
return;
}
else {
sheet.clear();
}
}
else {
sheet = ss.insertSheet(sheetName);
}
this.setSheetVersion(sheet, version);
const referenceRangeName = this.openPositionsRangeName;
sheet.getRange('A1:1').setFontWeight('bold').setHorizontalAlignment("center");
sheet.setFrozenRows(1);
sheet.getRange('A2:A').setNumberFormat('@');
sheet.getRange(2, 2, sheet.getMaxRows(), sheet.getMaxColumns()).setNumberFormat('#,##0.00000000;(#,##0.00000000);');
sheet.getRange('A1').setFormula(`IF(ISBLANK(INDEX(${referenceRangeName}, 1, 1)),,QUERY(${referenceRangeName}, "SELECT J, SUM(K) GROUP BY J PIVOT G ORDER BY J LABEL J 'Wallet'"))`);
sheet.autoResizeColumns(1, sheet.getMaxColumns());
};