-
Notifications
You must be signed in to change notification settings - Fork 28
/
HighlightAndAlert.ts
39 lines (37 loc) · 1.27 KB
/
HighlightAndAlert.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
function main(workbook: ExcelScript.Workbook) {
let table1 = workbook.getTable("Table1");
const rowCount = table1.getRowCount();
if (rowCount === 0) {
return;
}
workbook.getApplication().calculate(ExcelScript.CalculationType.full);
const amountDueCol = table1.getColumnByName('Amount Due');
const amountDueValues = amountDueCol.getRangeBetweenHeaderAndTotal().getValues();
let highestValue = amountDueValues[0][0];
let row = 0;
for (let i = 1; i < amountDueValues.length; i++) {
if (amountDueValues[i][0] > highestValue) {
highestValue = amountDueValues[i][0];
row = i;
}
}
// Set fill color to FFFF00 for range in table Table1 cell in row 0 on column Amount due
table1.getColumn("Amount due")
.getRangeBetweenHeaderAndTotal()
.getRow(row)
.getFormat()
.getFill()
.setColor("FFFF00");
let selectedSheet = workbook.getActiveWorksheet();
// Insert comment at cell InvoiceAmounts!F2
workbook.addComment(table1.getColumn("Amount due")
.getRangeBetweenHeaderAndTotal()
.getRow(row), {
mentions: [{
email: "AdeleV@M365x904181.OnMicrosoft.com",
id: 0,
name: "Adele Vance"
}],
richContent: "<at id=\"0\">Adele Vance</at> Please review this amount"
}, ExcelScript.ContentType.mention);
}