-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtool-a.html
40 lines (32 loc) · 1.27 KB
/
tool-a.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Taskpane</title>
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"></script>
</head>
<body>
<!-- Put a button on the task pane -->
<p>Tool-A</p>
<button id="run-btn" type="button">Run</button>
<script>
// Initialize Office.js
Office.onReady(function (info) { });
// Add a click event listener to the button
document.getElementById("run-btn").addEventListener("click", run);
// Based on 'Basic API call' sample from ScriptLab
async function run() {
await Excel.run(async (context) => {
const range = context.workbook.getSelectedRange();
range.format.fill.color = "yellow";
range.load("address");
await context.sync();
const sheets = context.workbook.worksheets;
sheets.getItem("Sheet1").getRange("A1").values = [["The selected address was " + range.address + "."]];
sheets.getItem("Sheet1").getRange("A2").values = [["Xin chào tôi là Long"]];
});
}
</script>
</body>
</html>