@@ -18,6 +18,7 @@ script:
18
18
document.getElementById("table-borders").addEventListener("click", () => tryCatch(tableBorders));
19
19
document.getElementById("table-indent-margin").addEventListener("click", () => tryCatch(tableIndentMargin));
20
20
document.getElementById("table-cell-alignment").addEventListener("click", () => tryCatch(tableCellAlignment));
21
+ document.getElementById("table-text-runs").addEventListener("click", () => tryCatch(tableTextRuns));
21
22
document.getElementById("table-from-shape").addEventListener("click", () => tryCatch(getTableFromShape));
22
23
document.getElementById("update-table-values").addEventListener("click", () => tryCatch(updateTableValues));
23
24
document.getElementById("setup").addEventListener("click", () => tryCatch(setup));
@@ -52,7 +53,7 @@ script:
52
53
await PowerPoint.run(async (context) => {
53
54
const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;
54
55
55
- // Add a table, specifying column widths and row heights
56
+ // Add a table, specifying column widths and row heights.
56
57
shapes.addTable(3, 4, {
57
58
columns: [{ columnWidth: 100 }, { columnWidth: 200 }, { columnWidth: 100 }, { columnWidth: 200 }],
58
59
rows: [{ rowHeight: 60 }, { rowHeight: 120 }, { rowHeight: 180 }]
@@ -101,7 +102,7 @@ script:
101
102
await PowerPoint.run(async (context) => {
102
103
const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;
103
104
104
- // Add a table, specifying font formatting and fill colors
105
+ // Add a table, specifying font formatting and fill colors.
105
106
shapes.addTable(3, 4, {
106
107
values: [
107
108
["A", "BB", "CCC", "DDDD"],
@@ -138,7 +139,7 @@ script:
138
139
await PowerPoint.run(async (context) => {
139
140
const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;
140
141
141
- // Add a table, specifying border styles
142
+ // Add a table, specifying border styles.
142
143
shapes.addTable(3, 4, {
143
144
values: [
144
145
["A", "BB", "CCC", "DDDD"],
@@ -201,6 +202,51 @@ script:
201
202
});
202
203
}
203
204
205
+ async function tableTextRuns() {
206
+ // Specifies the text runs of the cells in a table.
207
+ await PowerPoint.run(async (context) => {
208
+ const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;
209
+
210
+ // Add a table, specifying text runs.
211
+ shapes.addTable(3, 4, {
212
+ specificCellProperties: [
213
+ [
214
+ { text: "Title text", font: { bold: true } },
215
+ { text: "Title text", font: { bold: true } },
216
+ { text: "Title text", font: { bold: true } },
217
+ { text: "Title text", font: { bold: true } }
218
+ ],
219
+ [
220
+ { text: "Bold text", font: { bold: true } },
221
+ {
222
+ textRuns: [
223
+ { text: "Text runs with " },
224
+ { text: "Underlined text", font: { underline: PowerPoint.ShapeFontUnderlineStyle.double } },
225
+ { text: " and plain text" }
226
+ ]
227
+ },
228
+ { text: "Italicized text", font: { italic: true } },
229
+ { text: "Plain text" }
230
+ ],
231
+ [
232
+ { text: "Bold text", font: { bold: true } },
233
+ { text: "Underlined text", font: { underline: PowerPoint.ShapeFontUnderlineStyle.dotted } },
234
+ {
235
+ font: { bold: true },
236
+ textRuns: [
237
+ { text: "Text runs with " },
238
+ { text: "italicized text", font: { italic: true } },
239
+ { text: " and (inherited) bold text" }
240
+ ]
241
+ },
242
+ { text: "Italicized text", font: { italic: true } }
243
+ ]
244
+ ]
245
+ });
246
+ await context.sync();
247
+ });
248
+ }
249
+
204
250
async function getTableFromShape() {
205
251
// Gets the table from a shape.
206
252
await PowerPoint.run(async (context) => {
@@ -336,6 +382,9 @@ template:
336
382
<button id="table-cell-alignment" class="ms-Button">
337
383
<span class="ms-Button-label">Set horizontal and vertical alignments</span>
338
384
</button>
385
+ <button id="table-text-runs" class="ms-Button">
386
+ <span class="ms-Button-label">Set text runs</span>
387
+ </button>
339
388
<button id="table-from-shape" class="ms-Button">
340
389
<span class="ms-Button-label">Get selected table and log to console</span>
341
390
</button>
0 commit comments