-
Notifications
You must be signed in to change notification settings - Fork 0
/
InitSettingSheet.js
31 lines (24 loc) · 1.14 KB
/
InitSettingSheet.js
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
function initSettingSheet(sheetName) {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const settingSheet = ss.insertSheet(sheetName, ss.getActiveSheet().getIndex());
// Hide it immediately
settingSheet.hideSheet();
setColumn(settingSheet, 1, 1, 200);
setColumn(settingSheet, 1, 2, 350);
const initialColumnSize = 2;
const initialRowSize = 16;
settingSheet.deleteColumns(initialColumnSize+1, 26-initialColumnSize);
settingSheet.deleteRows(initialRowSize+1, 1000-initialRowSize);
const settingSheetRange = settingSheet.getRange(1, 1, initialRowSize, initialColumnSize);
settingSheetRange.setHorizontalAlignment("left").setVerticalAlignment("top");
// Set default setting variables
setValue(settingSheet, 1, 1, ONTOLOGY_IRI);
setValue(settingSheet, 2, 1, ONTOLOGY_ACRONYM);
setValue(settingSheet, 3, 1, BIOPORTAL_API_KEY);
// The sheet is protected only to the owner by default
const protection = settingSheet.protect().setDescription('Protected ' + sheetName + ' sheet');
const owner = ss.getOwner().getEmail();
protection.removeEditors(protection.getEditors());
protection.addEditors([owner]);
return settingSheet;
}