Skip to content

Commit ffc0846

Browse files
Merge pull request #972 from OfficeDev/main
[Admin] main -> prod
2 parents 3235268 + f577e2c commit ffc0846

File tree

60 files changed

+669
-708
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+669
-708
lines changed

samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ script:
189189
190190
await context.sync();
191191
192-
$(".conditional-formats").hide();
192+
document.querySelectorAll(".conditional-formats").forEach(element => {
193+
element.style.display = "none";
194+
});
193195
});
194196
}
195197

samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ script:
2424
await context.sync();
2525
2626
const readableXml = addLineBreaksToXML(xmlBlob.value);
27-
$("#display-xml").text(readableXml);
27+
document.getElementById("display-xml").textContent = readableXml;
2828
2929
// Store the XML part's ID in a setting.
3030
const settings = context.workbook.settings;
@@ -50,7 +50,7 @@ script:
5050
await context.sync();
5151
5252
const readableXml = addLineBreaksToXML(xmlBlob.value);
53-
$("#display-xml").text(readableXml);
53+
document.getElementById("display-xml").textContent = readableXml;
5454
await context.sync();
5555
}
5656
});
@@ -71,14 +71,14 @@ script:
7171
await context.sync();
7272
7373
if (customXmlPart.isNullObject) {
74-
$("#display-xml").text(`The XML part with the id ${xmlPartIDSetting.value} has been deleted.`);
74+
document.getElementById("display-xml").textContent = `The XML part with the id ${xmlPartIDSetting.value} has been deleted.`;
7575
7676
// Delete the unneeded setting too.
7777
xmlPartIDSetting.delete();
7878
} else {
7979
const readableXml = addLineBreaksToXML(xmlBlob.value);
8080
const strangeMessage = `This is strange. The XML part with the id ${xmlPartIDSetting.value} has not been deleted:\n${readableXml}`
81-
$("#display-xml").text(strangeMessage);
81+
document.getElementById("display-xml").textContent = strangeMessage;
8282
}
8383
8484
await context.sync();

samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ script:
1414
1515
async function createCustomXmlPart() {
1616
await Excel.run(async (context) => {
17-
$("#display-xml").text("");
17+
document.getElementById("display-xml").textContent = "";
1818
1919
// You must have the xmlns attribute to populate the
2020
// CustomXml.namespaceUri property.
@@ -26,15 +26,15 @@ script:
2626
2727
// Make it a bit more readable.
2828
const readableXml = xmlBlob.value.replace(/></g, ">\n<");
29-
$("#display-xml").text(readableXml);
29+
document.getElementById("display-xml").textContent = readableXml;
3030
3131
await context.sync();
3232
});
3333
}
3434
3535
async function testForUniqueNamespace() {
3636
await Excel.run(async (context) => {
37-
$("#display-xml").text("");
37+
document.getElementById("display-xml").textContent = "";
3838
const contosoNamespace = "http://schemas.contoso.com/review/1.0";
3939
const customXmlParts = context.workbook.customXmlParts;
4040
const filteredXmlParts = customXmlParts.getByNamespace(contosoNamespace);
@@ -51,8 +51,8 @@ script:
5151
// Make it a bit more readable.
5252
const readableXml = xmlBlob.value.replace(/></g, ">\n<");
5353
54-
$("#display-xml").text(`The only XML part in the namespace ${contosoNamespace} is:
55-
${readableXml}`);
54+
document.getElementById("display-xml").textContent = `The only XML part in the namespace ${contosoNamespace} is:
55+
${readableXml}`;
5656
5757
} else {
5858
console.log(`There are ${numberOfPartsInNamespace.value} XML parts with namespace ${contosoNamespace}. There should be exactly 1.`);
@@ -64,7 +64,7 @@ script:
6464
6565
async function deleteAllCustomXmlParts() {
6666
await Excel.run(async (context) => {
67-
$("#display-xml").text("");
67+
document.getElementById("display-xml").textContent = "";
6868
const customXmlParts = context.workbook.customXmlParts;
6969
customXmlParts.load("items");
7070

samples/excel/20-data-types/data-types-web-image.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ script:
1717
// This function inserts a web image into the currently selected cell.
1818
await Excel.run(async (context) => {
1919
// Retrieve image data from the task pane and then clear the input fields.
20-
const imageUrl = $("#url").val() as string;
21-
const imageAltText = $("#alt-text").val() as string;
20+
const imageUrl = (document.getElementById("url") as HTMLInputElement).value;
21+
const imageAltText = (document.getElementById("alt-text") as HTMLInputElement).value;
2222
clearForm();
2323
2424
// Load the active cell.
@@ -65,8 +65,8 @@ script:
6565
}
6666
6767
// Assign image data to corresponding input fields in the task pane.
68-
$("#url").val(webImageUrl);
69-
$("#alt-text").val(webImageAltText);
68+
(document.getElementById("url") as HTMLInputElement).value = webImageUrl;
69+
(document.getElementById("alt-text") as HTMLInputElement).value = webImageAltText;
7070
});
7171
}
7272
@@ -95,8 +95,8 @@ script:
9595
9696
async function clearForm() {
9797
// Clear the input fields in the task pane.
98-
$("#url").val("");
99-
$("#alt-text").val("");
98+
(document.getElementById("url") as HTMLInputElement).value = "";
99+
(document.getElementById("alt-text") as HTMLInputElement).value = "";
100100
}
101101
102102
async function setup() {

samples/excel/26-document/custom-properties.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ script:
1919
async function setCustomDocProperty() {
2020
await Excel.run(async (context) => {
2121
// Get the key/value pair from the task pane.
22-
const userKey = $("#key").text();
23-
const userValue = $("#value").text();
22+
const userKey = document.getElementById("key").textContent;
23+
const userValue = document.getElementById("value").textContent;
2424
2525
// Add the custom property.
2626
const customDocProperties = context.workbook.properties.custom;
@@ -50,8 +50,8 @@ script:
5050
async function setCustomWorksheetProperty() {
5151
await Excel.run(async (context) => {
5252
// Get the key/value pair from the task pane.
53-
const userKey = $("#key").text();
54-
const userValue = $("#value").text();
53+
const userKey = document.getElementById("key").textContent;
54+
const userValue = document.getElementById("value").textContent;
5555
5656
// Add the custom property.
5757
const customWorksheetProperties = context.workbook.worksheets.getActiveWorksheet().customProperties;

samples/excel/26-document/get-file-in-slices-async.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ script:
3535
console.log("Received the full contents of the file.");
3636
3737
let base64string = base64js.fromByteArray(byteArray);
38-
$('#file-contents').val(base64string).show();
38+
const fileContentsElement = document.getElementById("file-contents") as HTMLTextAreaElement;
39+
fileContentsElement.value = base64string;
40+
fileContentsElement.style.display = "block";
3941
4042
console.log("The Base64-encoded string that represents the current document has been written to the text box. To validate the string, use the \"Create workbook from string\" button.");
4143
}
@@ -82,7 +84,9 @@ script:
8284
}
8385
8486
async function newWorkbookFromFile() {
85-
await Excel.createWorkbook($('#file-contents').text()).catch(function (error) {
87+
const fileContentsElement = document.getElementById("file-contents");
88+
const fileContentsText = fileContentsElement.textContent;
89+
await Excel.createWorkbook(fileContentsText).catch(function (error) {
8690
console.error(error);
8791
});
8892
}
@@ -169,8 +173,8 @@ template:
169173
<span class="ms-Button-label">Get file</span>
170174
</button>
171175
<br/>
172-
<textarea id="file-contents">
173-
</textarea>
176+
<textarea id="file-contents">
177+
</textarea>
174178
</section>
175179
<section class="ms-Fabric samples ms-font-m">
176180
<h3>Create a new workbook</h3>

samples/excel/42-range/range-find.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ script:
2626
2727
// NOTE: If no match is found, an ItemNotFound error
2828
// is thrown when Range.find is evaluated.
29-
const foundRange = searchRange.find($("#searchText").val().toString(), {
29+
const searchText = (document.getElementById("searchText") as HTMLTextAreaElement).value;
30+
const foundRange = searchRange.find(searchText, {
3031
completeMatch: isCompleteMatchToggle,
3132
matchCase: isMatchCaseToggle,
3233
searchDirection: searchDirectionToggle
@@ -45,7 +46,8 @@ script:
4546
const sheet = context.workbook.worksheets.getItem("Sample");
4647
const table = sheet.tables.getItem("ExpensesTable");
4748
const searchRange = table.getRange();
48-
const foundRange = searchRange.findOrNullObject($("#searchText").val().toString(), {
49+
const searchText = (document.getElementById("searchText") as HTMLTextAreaElement).value;
50+
const foundRange = searchRange.findOrNullObject(searchText, {
4951
completeMatch: isCompleteMatchToggle,
5052
matchCase: isMatchCaseToggle,
5153
searchDirection: searchDirectionToggle

samples/excel/44-shape/shape-images.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ api_set:
88
script:
99
content: |-
1010
document.getElementById("setup").addEventListener("click", () => tryCatch(setup));
11-
$("#selectedFile").on("change", () => tryCatch(readImageFromFile));
11+
document.getElementById("selectedFile").addEventListener("change", () => tryCatch(readImageFromFile));
1212
document.getElementById("flipImage").addEventListener("click", () => tryCatch(flipImage));
1313
document.getElementById("getImageFormat").addEventListener("click", () => tryCatch(getImageFormat));
1414
document.getElementById("writeOutImageString").addEventListener("click", () => tryCatch(writeOutImageString));
1515
1616
async function readImageFromFile() {
17-
const myFile = <HTMLInputElement>document.getElementById("selectedFile");
17+
const myFile = document.getElementById("selectedFile") as HTMLInputElement;
1818
const reader = new FileReader();
1919
2020
reader.onload = (event) => {

samples/excel/50-workbook/create-workbook.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ api_set:
99
script:
1010
content: |-
1111
document.getElementById("create-new-blank-workbook").addEventListener("click", () => tryCatch(createBlankWorkbook));
12-
$("#file").on("change", () => tryCatch(createWorkbookFromExisting));
12+
document.getElementById("file").addEventListener("change", () => tryCatch(createWorkbookFromExisting));
1313
1414
async function createBlankWorkbook() {
1515
await Excel.run(async (context) => {
@@ -18,7 +18,7 @@ script:
1818
}
1919
2020
async function createWorkbookFromExisting() {
21-
const myFile = <HTMLInputElement>document.getElementById("file");
21+
const myFile = document.getElementById("file") as HTMLInputElement;
2222
const reader = new FileReader();
2323
2424
reader.onload = ((event) => {

samples/excel/50-workbook/workbook-insert-external-worksheets.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ api_set:
77
ExcelAPI: '1.13'
88
script:
99
content: |-
10-
$("#file").on("change", getBase64);
10+
document.getElementById("file").addEventListener("change", getBase64);
1111
document.getElementById("insert-sheets").addEventListener("click", () => tryCatch(insertSheets));
1212
1313
let externalWorkbook;
1414
1515
async function getBase64() {
1616
// Retrieve the file and set up an HTML FileReader element.
17-
const myFile = <HTMLInputElement>document.getElementById("file");
17+
const myFile = document.getElementById("file") as HTMLInputElement;
1818
const reader = new FileReader();
1919
2020
reader.onload = (event) => {

0 commit comments

Comments
 (0)