diff --git a/playlists-prod/excel.yaml b/playlists-prod/excel.yaml index 9a3f0428..3b67eee0 100644 --- a/playlists-prod/excel.yaml +++ b/playlists-prod/excel.yaml @@ -173,8 +173,8 @@ fileName: comment-basics.yaml description: 'Adds, edits, and removes comments.' rawUrl: >- - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-basics.yaml - group: Comment + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml + group: Comments And Notes api_set: ExcelApi: '1.10' - id: excel-comment-mentions @@ -182,8 +182,8 @@ fileName: comment-mentions.yaml description: Mentions someone in a comment. rawUrl: >- - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-mentions.yaml - group: Comment + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-mentions.yaml + group: Comments And Notes api_set: ExcelApi: '1.11' - id: excel-comment-replies @@ -191,8 +191,8 @@ fileName: comment-replies.yaml description: 'Adds, edits, and removes comment replies.' rawUrl: >- - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-replies.yaml - group: Comment + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-replies.yaml + group: Comments And Notes api_set: ExcelApi: '1.10' - id: excel-comment-resolution @@ -200,10 +200,19 @@ fileName: comment-resolution.yaml description: Resolves and reopens a comment thread. rawUrl: >- - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-resolution.yaml - group: Comment + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-resolution.yaml + group: Comments And Notes api_set: ExcelApi: '1.10' +- id: excel-note-basics + name: Notes + fileName: excel-note-basics.yaml + description: 'Adds, edits, and removes notes.' + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + group: Comments And Notes + api_set: + ExcelApi: '1.18' - id: excel-range-conditional-formatting-basic name: Basic conditional formatting fileName: conditional-formatting-basic.yaml @@ -896,6 +905,15 @@ group: Range api_set: ExcelAPI: '1.15' +- id: excel-cell-controls + name: Checkboxes + fileName: range-cell-control.yaml + description: This sample shows how to add and remove checkboxes from a table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + group: Range + api_set: + ExcelApi: '1.18' - id: excel-shape-create-and-delete name: Create and delete geometric shapes fileName: shape-create-and-delete.yaml diff --git a/playlists/excel.yaml b/playlists/excel.yaml index b10fa440..2a8b5c90 100644 --- a/playlists/excel.yaml +++ b/playlists/excel.yaml @@ -173,8 +173,8 @@ fileName: comment-basics.yaml description: 'Adds, edits, and removes comments.' rawUrl: >- - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comment/comment-basics.yaml - group: Comment + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-basics.yaml + group: Comments And Notes api_set: ExcelApi: '1.10' - id: excel-comment-mentions @@ -182,8 +182,8 @@ fileName: comment-mentions.yaml description: Mentions someone in a comment. rawUrl: >- - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comment/comment-mentions.yaml - group: Comment + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-mentions.yaml + group: Comments And Notes api_set: ExcelApi: '1.11' - id: excel-comment-replies @@ -191,8 +191,8 @@ fileName: comment-replies.yaml description: 'Adds, edits, and removes comment replies.' rawUrl: >- - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comment/comment-replies.yaml - group: Comment + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-replies.yaml + group: Comments And Notes api_set: ExcelApi: '1.10' - id: excel-comment-resolution @@ -200,10 +200,19 @@ fileName: comment-resolution.yaml description: Resolves and reopens a comment thread. rawUrl: >- - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comment/comment-resolution.yaml - group: Comment + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-resolution.yaml + group: Comments And Notes api_set: ExcelApi: '1.10' +- id: excel-note-basics + name: Notes + fileName: excel-note-basics.yaml + description: 'Adds, edits, and removes notes.' + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/excel-note-basics.yaml + group: Comments And Notes + api_set: + ExcelApi: '1.18' - id: excel-range-conditional-formatting-basic name: Basic conditional formatting fileName: conditional-formatting-basic.yaml @@ -896,6 +905,15 @@ group: Range api_set: ExcelAPI: '1.15' +- id: excel-cell-controls + name: Checkboxes + fileName: range-cell-control.yaml + description: This sample shows how to add and remove checkboxes from a table. + rawUrl: >- + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-cell-control.yaml + group: Range + api_set: + ExcelApi: '1.18' - id: excel-shape-create-and-delete name: Create and delete geometric shapes fileName: shape-create-and-delete.yaml diff --git a/samples/excel/12-comment/comment-basics.yaml b/samples/excel/12-comments-and-notes/comment-basics.yaml similarity index 100% rename from samples/excel/12-comment/comment-basics.yaml rename to samples/excel/12-comments-and-notes/comment-basics.yaml diff --git a/samples/excel/12-comment/comment-mentions.yaml b/samples/excel/12-comments-and-notes/comment-mentions.yaml similarity index 100% rename from samples/excel/12-comment/comment-mentions.yaml rename to samples/excel/12-comments-and-notes/comment-mentions.yaml diff --git a/samples/excel/12-comment/comment-replies.yaml b/samples/excel/12-comments-and-notes/comment-replies.yaml similarity index 100% rename from samples/excel/12-comment/comment-replies.yaml rename to samples/excel/12-comments-and-notes/comment-replies.yaml diff --git a/samples/excel/12-comment/comment-resolution.yaml b/samples/excel/12-comments-and-notes/comment-resolution.yaml similarity index 100% rename from samples/excel/12-comment/comment-resolution.yaml rename to samples/excel/12-comments-and-notes/comment-resolution.yaml diff --git a/samples/excel/12-comments-and-notes/excel-note-basics.yaml b/samples/excel/12-comments-and-notes/excel-note-basics.yaml new file mode 100644 index 00000000..d8a65e18 --- /dev/null +++ b/samples/excel/12-comments-and-notes/excel-note-basics.yaml @@ -0,0 +1,162 @@ +order: 5 +id: excel-note-basics +name: Notes +description: 'Adds, edits, and removes notes.' +host: EXCEL +api_set: + ExcelApi: '1.18' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("add-note-to-selected-cell").addEventListener("click", () => tryCatch(addNoteToSelectedCell)); + document.getElementById("add-note-to-cell").addEventListener("click", () => tryCatch(addNoteToCell)); + document.getElementById("change-note-visibility").addEventListener("click", () => tryCatch(changeNoteVisibility)); + document.getElementById("edit-note-content").addEventListener("click", () => tryCatch(editNoteContent)); + document.getElementById("edit-note-size").addEventListener("click", () => tryCatch(editNoteSize)); + document.getElementById("delete-note").addEventListener("click", () => tryCatch(deleteNote)); + + async function addNoteToSelectedCell() { + // This function adds a note to the selected cell. + await Excel.run(async (context) => { + const selectedRange = context.workbook.getSelectedRange(); + + // Note that an InvalidArgument error is thrown if multiple cells are selected. + context.workbook.notes.add(selectedRange, "The first note."); + await context.sync(); + }); + } + + async function addNoteToCell() { + // This function adds a note to cell A2. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + + // Note that an InvalidArgument error is thrown if multiple cells are passed to `notes.add`. + sheet.notes.add("A2", "The second note."); + await context.sync(); + }); + } + + async function changeNoteVisibility() { + // This function sets the note on cell A1 to visible. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const firstNote = sheet.notes.getItem("A1"); + + firstNote.load(); + await context.sync(); + + firstNote.visible = true; + }); + } + + async function editNoteContent() { + // This function changes the content in the first note. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.content = "Changing the content of the first note."; + await context.sync(); + }); + } + + async function editNoteSize() { + // This function changes the height and width of the first note. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.height = 200; + note.width = 400; + await context.sync(); + }); + } + + async function deleteNote() { + // This function deletes the note from cell A2. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItem("A2"); + note.delete(); + + await context.sync(); + }); + } + + /** Set up Sample worksheet. */ + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Notes").delete(); + const sheet = context.workbook.worksheets.add("Notes"); + + sheet.activate(); + await context.sync(); + }); + } + + /** Default helper for invoking an action and handling errors. */ + async function tryCatch(callback) { + try { + await callback(); + } catch (error) { + // Note: In a production add-in, you'd want to notify the user through your add-in's UI. + console.error(error); + } + } + language: typescript +template: + content: |- +
+

This sample shows how to work with notes: Add notes, edit content, size, and visibility, and remove notes.

+
+
+

Setup

+ +
+
+

Try it out

+ +

+ +

+ +

+ +

+ +

+ +

+ language: html +style: + content: |- + section.samples { + margin-top: 20px; + } + + section.samples .ms-Button, section.setup .ms-Button { + display: block; + margin-bottom: 5px; + margin-left: 20px; + min-width: 80px; + } + language: css +libraries: |- + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://appsforoffice.microsoft.com/lib/1/hosted/office.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/samples/excel/42-range/range-cell-control.yaml b/samples/excel/42-range/range-cell-control.yaml new file mode 100644 index 00000000..a207ebd8 --- /dev/null +++ b/samples/excel/42-range/range-cell-control.yaml @@ -0,0 +1,164 @@ +order: 23 +id: excel-cell-controls +name: Checkboxes +description: This sample shows how to add and remove checkboxes from a table. +host: EXCEL +api_set: + ExcelApi: '1.18' +script: + content: |- + document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); + document.getElementById("add-checkboxes").addEventListener("click", () => tryCatch(addCheckboxes)); + document.getElementById("change-checkbox").addEventListener("click", () => tryCatch(changeCheckbox)); + document.getElementById("remove-checkboxes").addEventListener("click", () => tryCatch(removeCheckboxes)); + document.getElementById("remove-content").addEventListener("click", () => tryCatch(removeContent)); + + async function addCheckboxes() { + // Add checkboxes to the table. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); + }); + } + + async function changeCheckbox() { + // Change the value of the checkbox in B3. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const range = sheet.getRange("B3"); + + range.values = [["TRUE"]]; + await context.sync(); + }); + } + + async function removeCheckboxes() { + // Remove checkboxes from the table. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the checkboxes back to boolean values. + range.control = { + type: Excel.CellControlType.empty + }; + await context.sync(); + }); + } + + async function removeContent() { + // Remove all content from the Analysis column. + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Clear all the data from the second column. + range.clearOrResetContents(); + await context.sync(); + }); + } + + // Set up the sample content. + async function setup() { + await Excel.run(async (context) => { + context.workbook.worksheets.getItemOrNullObject("Sample").delete(); + const sheet = context.workbook.worksheets.add("Sample"); + + const fruitTable = sheet.tables.add("A1:B1", true /*hasHeaders*/); + fruitTable.name = "FruitTable"; + + fruitTable.getHeaderRowRange().values = [["Fruit", "Analysis"]]; + + fruitTable.rows.add(null /*add at the end*/, [ + ["Apple", "TRUE"], + ["Kale", "FALSE"], + ["Orange", "TRUE"], + ["Pear", "TRUE"], + ["Mango", "TRUE"], + ["Dog", "FALSE"], + ["Strawberry", "TRUE"], + ["Chair", "FALSE"], + ["Tomato", "UNKNOWN"] /* Only boolean values will render as checkboxes. */ + ]); + + sheet.getUsedRange().format.autofitColumns(); + sheet.getUsedRange().format.autofitRows(); + + sheet.activate(); + + await context.sync(); + }); + } + + /** Default helper for invoking an action and handling errors. */ + async function tryCatch(callback) { + try { + await callback(); + } catch (error) { + // Note: In a production add-in, you'd want to notify the user through your add-in's UI. + console.error(error); + } + } + language: typescript +template: + content: |- +
+

This sample creates and table and then shows how to add, remove, and change checkboxes in the table. +

+
+
+

Set up

+ +
+
+

Try it out

+ +
+ +
+ +
+ +
+ language: html +style: + content: |- + section.samples { + margin-top: 20px; + } + + section.samples .ms-Button, section.setup .ms-Button { + display: block; + margin-bottom: 5px; + margin-left: 20px; + min-width: 80px; + } + language: css +libraries: |- + https://appsforoffice.microsoft.com/lib/1/hosted/office.js + https://appsforoffice.microsoft.com/lib/1/hosted/office.d.ts + + https://unpkg.com/office-ui-fabric-core@11.1.0/dist/css/fabric.min.css + https://unpkg.com/office-ui-fabric-js@1.5.0/dist/css/fabric.components.min.css \ No newline at end of file diff --git a/snippet-extractor-metadata/excel.xlsx b/snippet-extractor-metadata/excel.xlsx index 0daeeb2d..5c530168 100644 Binary files a/snippet-extractor-metadata/excel.xlsx and b/snippet-extractor-metadata/excel.xlsx differ diff --git a/snippet-extractor-output/snippets.yaml b/snippet-extractor-output/snippets.yaml index 0ce86d48..504cc0a9 100644 --- a/snippet-extractor-output/snippets.yaml +++ b/snippet-extractor-output/snippets.yaml @@ -445,6 +445,46 @@ context.application.calculate(Excel.CalculationType.recalculate); await context.sync(); }); +'Excel.CellControl:class': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Add checkboxes to the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); + }); +'Excel.CellControlType:enum': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Add checkboxes to the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); + }); 'Excel.CellPropertiesFill#color:member': - >- // Link to full sample: @@ -1669,6 +1709,26 @@ chart.dataLabels.format.font.color = "black"; chart.title.text = "Bicycle Parts Quarterly Sales"; + await context.sync(); + }); +'Excel.CheckboxCellControl:interface': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Add checkboxes to the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; await context.sync(); }); 'Excel.ClearApplyTo:enum': @@ -1732,7 +1792,7 @@ 'Excel.Comment#content:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-basics.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml await Excel.run(async (context) => { @@ -1744,7 +1804,7 @@ 'Excel.Comment#delete:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-basics.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml await Excel.run(async (context) => { @@ -1754,7 +1814,7 @@ 'Excel.Comment#load:member(2)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-basics.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml await Excel.run(async (context) => { @@ -1768,7 +1828,7 @@ 'Excel.Comment#resolved:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-resolution.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-resolution.yaml await Excel.run(async (context) => { @@ -1779,7 +1839,7 @@ 'Excel.CommentCollection#add:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-basics.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml await Excel.run(async (context) => { @@ -1907,7 +1967,7 @@ 'Excel.CommentReply#content:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-replies.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-replies.yaml await Excel.run(async (context) => { @@ -1925,7 +1985,7 @@ 'Excel.CommentReply#delete:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-replies.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-replies.yaml await Excel.run(async (context) => { @@ -1938,7 +1998,7 @@ 'Excel.CommentReplyCollection#add:member(1)': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-replies.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-replies.yaml await Excel.run(async (context) => { @@ -1951,7 +2011,7 @@ 'Excel.CommentRichContent#mentions:member': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-mentions.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-mentions.yaml await Excel.run(async (context) => { @@ -2688,7 +2748,7 @@ 'Excel.ContentType:enum': - >- // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-mentions.yaml + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-mentions.yaml await Excel.run(async (context) => { @@ -4145,6 +4205,158 @@ await context.sync(); }); +'Excel.Note:class': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function changes the height and width of the first note. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.height = 200; + note.width = 400; + await context.sync(); + }); +'Excel.Note#content:member': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function changes the content in the first note. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.content = "Changing the content of the first note."; + await context.sync(); + }); +'Excel.Note#height:member': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function changes the height and width of the first note. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.height = 200; + note.width = 400; + await context.sync(); + }); +'Excel.Note#visible:member': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function sets the note on cell A1 to visible. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const firstNote = sheet.notes.getItem("A1"); + + firstNote.load(); + await context.sync(); + + firstNote.visible = true; + }); +'Excel.Note#width:member': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function changes the height and width of the first note. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.height = 200; + note.width = 400; + await context.sync(); + }); +'Excel.Note#delete:member(1)': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function deletes the note from cell A2. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItem("A2"); + note.delete(); + + await context.sync(); + }); +'Excel.NoteCollection:class': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function adds a note to the selected cell. + + await Excel.run(async (context) => { + const selectedRange = context.workbook.getSelectedRange(); + + // Note that an InvalidArgument error is thrown if multiple cells are selected. + context.workbook.notes.add(selectedRange, "The first note."); + await context.sync(); + }); +'Excel.NoteCollection#add:member(1)': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function adds a note to the selected cell. + + await Excel.run(async (context) => { + const selectedRange = context.workbook.getSelectedRange(); + + // Note that an InvalidArgument error is thrown if multiple cells are selected. + context.workbook.notes.add(selectedRange, "The first note."); + await context.sync(); + }); +'Excel.NoteCollection#getItem:member(1)': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function sets the note on cell A1 to visible. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const firstNote = sheet.notes.getItem("A1"); + + firstNote.load(); + await context.sync(); + + firstNote.visible = true; + }); +'Excel.NoteCollection#getItemAt:member(1)': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml + + + // This function changes the content in the first note. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getItem("Notes"); + const note = sheet.notes.getItemAt(0); + note.content = "Changing the content of the first note."; + await context.sync(); + }); 'Excel.NumberFormatInfo#numberDecimalSeparator:member': - >- // Link to full sample: @@ -4904,6 +5116,24 @@ sumCell.format.autofitColumns(); await context.sync(); }); +'Excel.Range#clearOrResetContents:member(1)': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Remove all content from the Analysis column. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Clear all the data from the second column. + range.clearOrResetContents(); + await context.sync(); + }); 'Excel.Range#copyFrom:member(1)': - >- // Link to full sample: @@ -4920,6 +5150,26 @@ sheet.getRange("G2").copyFrom("A1:E1", Excel.RangeCopyType.formulas); await context.sync(); }); +'Excel.Range#control:member': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Add checkboxes to the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); + }); 'Excel.Range#find:member(1)': - >- // Link to full sample: @@ -5669,6 +5919,21 @@ sheet.getRange("A1:R10").ungroup(Excel.GroupOption.byColumns); await context.sync(); }); +'Excel.Range#values:member': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Change the value of the checkbox in B3. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + const range = sheet.getRange("B3"); + + range.values = [["TRUE"]]; + await context.sync(); + }); 'Excel.Range#valuesAsJson:member': - >- // Link to full sample: @@ -6907,6 +7172,46 @@ console.log("Worksheet Id : " + worksheet.name); }); } +'Excel.TableCollection:class': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Add checkboxes to the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); + }); +'Excel.TableCollection#getItem:member(1)': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Remove checkboxes from the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the checkboxes back to boolean values. + range.control = { + type: Excel.CellControlType.empty + }; + await context.sync(); + }); 'Excel.TableCollection#onChanged:member': - >- // Link to full sample: @@ -6920,6 +7225,64 @@ await context.sync(); console.log("A handler has been registered for the table collection onChanged event"); }); +'Excel.TableColumn#getDataBodyRange:member(1)': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Add checkboxes to the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); + }); +'Excel.TableColumnCollection:class': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Add checkboxes to the table. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Change the boolean values to checkboxes. + range.control = { + type: Excel.CellControlType.checkbox + }; + await context.sync(); + }); +'Excel.TableColumnCollection#getItem:member(1)': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml + + + // Remove all content from the Analysis column. + + await Excel.run(async (context) => { + const sheet = context.workbook.worksheets.getActiveWorksheet(); + + // Get the second column in the table, without the header. + const range = sheet.tables.getItem("FruitTable").columns.getItem("Analysis").getDataBodyRange(); + + // Clear all the data from the second column. + range.clearOrResetContents(); + await context.sync(); + }); 'Excel.TableSelectionChangedEventArgs#address:member': - >- // Link to full sample: diff --git a/view-prod/excel.json b/view-prod/excel.json index 3ff4c77a..b267d8b8 100644 --- a/view-prod/excel.json +++ b/view-prod/excel.json @@ -17,10 +17,11 @@ "excel-chart-title-format": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-title-format.yaml", "excel-chart-data-source": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-source.yaml", "excel-chart-trendlines": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-trendlines.yaml", - "excel-comment-basics": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-basics.yaml", - "excel-comment-mentions": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-mentions.yaml", - "excel-comment-replies": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-replies.yaml", - "excel-comment-resolution": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-resolution.yaml", + "excel-comment-basics": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml", + "excel-comment-mentions": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-mentions.yaml", + "excel-comment-replies": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-replies.yaml", + "excel-comment-resolution": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-resolution.yaml", + "excel-note-basics": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/excel-note-basics.yaml", "excel-range-conditional-formatting-basic": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml", "excel-range-conditional-formatting-advanced": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml", "excel-custom-functions-basic": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/16-custom-functions/basic-function.yaml", @@ -92,6 +93,7 @@ "excel-range-get-range-edge": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-get-range-edge.yaml", "excel-direct-dependents": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-direct-dependents.yaml", "excel-range-dependents": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-dependents.yaml", + "excel-cell-controls": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-cell-control.yaml", "excel-shape-create-and-delete": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-create-and-delete.yaml", "excel-shape-images": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-images.yaml", "excel-shape-lines": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml", diff --git a/view/excel.json b/view/excel.json index 7f9d59ff..c805307d 100644 --- a/view/excel.json +++ b/view/excel.json @@ -17,10 +17,11 @@ "excel-chart-title-format": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-title-format.yaml", "excel-chart-data-source": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-data-source.yaml", "excel-chart-trendlines": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/10-chart/chart-trendlines.yaml", - "excel-comment-basics": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comment/comment-basics.yaml", - "excel-comment-mentions": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comment/comment-mentions.yaml", - "excel-comment-replies": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comment/comment-replies.yaml", - "excel-comment-resolution": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comment/comment-resolution.yaml", + "excel-comment-basics": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-basics.yaml", + "excel-comment-mentions": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-mentions.yaml", + "excel-comment-replies": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-replies.yaml", + "excel-comment-resolution": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/comment-resolution.yaml", + "excel-note-basics": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/12-comments-and-notes/excel-note-basics.yaml", "excel-range-conditional-formatting-basic": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/14-conditional-formatting/conditional-formatting-basic.yaml", "excel-range-conditional-formatting-advanced": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/14-conditional-formatting/conditional-formatting-advanced.yaml", "excel-custom-functions-basic": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/16-custom-functions/basic-function.yaml", @@ -92,6 +93,7 @@ "excel-range-get-range-edge": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-get-range-edge.yaml", "excel-direct-dependents": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-direct-dependents.yaml", "excel-range-dependents": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-dependents.yaml", + "excel-cell-controls": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/42-range/range-cell-control.yaml", "excel-shape-create-and-delete": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-create-and-delete.yaml", "excel-shape-images": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-images.yaml", "excel-shape-lines": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/44-shape/shape-lines.yaml",