-
Notifications
You must be signed in to change notification settings - Fork 803
/
taskpane.html
37 lines (30 loc) · 1.25 KB
/
taskpane.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
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. -->
<!DOCTYPE html>
<html>
<head>
<!-- Office JavaScript API -->
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>
</head>
<body>
<p>This add-in will set cell A1 to the value 'Hello world!'.</p>
<button id="helloButton">Say hello</button>
<!-- The following image URL tracks diagnostic data for this sample add-in. Please remove the image tag if you reuse this sample in your own code project. -->
<img src="https://pnptelemetry.azurewebsites.net/pnp-officeaddins/samples/excel-add-in-hello-world-run" />
</body>
<script>
Office.onReady((info) => {
// Check that we loaded into Excel
if (info.host === Office.HostType.Excel) {
document.getElementById("helloButton").onclick = sayHello;
}
});
function sayHello() {
Excel.run(context => {
// Insert text 'Hello world!' into cell A1.
context.workbook.worksheets.getActiveWorksheet().getRange("A1").values = [['Hello world!']];
// sync the context to run the previous API call, and return.
return context.sync();
});
}
</script>
</html>