Skip to content

Commit 5937344

Browse files
[PowerPoint] (tables) Change way to update values in existing table (#5153)
* [PowerPoint] (tables) Unable to update values in existing table * Remove unneeded code statement * Update how to update a table cell value * Fix punctuation
1 parent 37bd198 commit 5937344

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

docs/powerpoint/work-with-tables.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Work with tables using the PowerPoint JavaScript API
33
description: Learn how to create tables and control formatting using the PowerPoint JavaScript API.
44
ms.topic: how-to
5-
ms.date: 04/30/2025
5+
ms.date: 05/02/2025
66
ms.localizationpriority: medium
77
---
88

@@ -383,7 +383,7 @@ The previous sample creates a table with two merged areas as shown in the follow
383383

384384
## Get and set table cell values
385385

386-
After a table is created you can get or set string values in the cells. Note that this is the only part of a table you can change. You can't change borders, fonts, widths, or other cell properties. If you need to update a table, delete it and recreate it. The following code sample shows how to find an existing table and set a new value for a cell in the table.
386+
After a table is created, you can get or set string values in the cells. Note that this is the only part of a table you can change. You can't change borders, fonts, widths, or other cell properties. If you need to update a table, delete it and recreate it. The following code sample shows how to find an existing table and set a new value for a cell in the table.
387387

388388
```javascript
389389
await PowerPoint.run(async (context) => {
@@ -394,13 +394,11 @@ await PowerPoint.run(async (context) => {
394394
// Find the first shape of type table.
395395
const shape = shapes.items.find((shape) => shape.type === PowerPoint.ShapeType.table)
396396
const table = shape.getTable();
397-
table.load("values");
397+
table.load();
398398
await context.sync();
399399
// Set the value of the specified table cell.
400-
let values = table.values;
401-
values[1][1] = "A new value";
402-
table.values = values;
403-
await context.sync();
400+
const cell = table.getCellOrNullObject(1, 1);
401+
cell.text = "A new value";
404402
});
405403
```
406404

0 commit comments

Comments
 (0)