-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopulate.ts
51 lines (41 loc) · 1.31 KB
/
populate.ts
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
49
50
51
function populate() {
const setores = scrap();
try {
for (const [_, [setor, funcionarios]] of Object.entries(setores)) {
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
const sheet =
spreadsheet.getSheetByName(setor.sigla) ??
spreadsheet.insertSheet(setor.sigla);
sheet.clear();
sheet
.getRange(1, 1, 1, 2)
.setValues([[setor.nome, '']])
.mergeAcross()
.setFontSize(14)
.setFontWeight('bold')
.setHorizontalAlignment('center')
.setBackground(setor.tabColor);
sheet
.getRange(2, 1, 1, 2)
.setValues([['Nome', 'SEDUC']])
.setFontWeight('bold');
sheet.getRange(3, 1, funcionarios.length, 2).setValues(
funcionarios.map(([nome, seduc]) => {
return [
nome,
`=HYPERLINK("https://www.documentos.spsempapel.sp.gov.br/siga/app/pessoa/exibir?sigla=${seduc}","${seduc}")`,
];
}),
);
sheet
.getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn())
.setFontSize(13)
.applyRowBanding(setor.bandingColor);
sheet.autoResizeColumns(1, 2);
sheet.autoResizeRows(1, sheet.getLastRow());
sheet.setTabColor(setor.tabColor);
}
} catch (error) {
console.log(error);
}
}