Hongbo Miao
Hongbo Miao

Reputation: 49944

How to update a specific row of a table in Excel using Microsoft Graph?

I try to update a specific row of a table in Excel using Microsoft Graph.

I didn't find any document in the table section.

For example, I want to update No. 6 row (index 5).

Is there any way like this? Thanks

PATCH:
https://graph.microsoft.com/beta/me/drive/items/12345/workbook/tables/Table1/rows/update

{
  "index": 5,
  "values": [
    [1, 2, 3]
  ]
}

Upvotes: 5

Views: 2891

Answers (1)

Sudhi Ramamurthy
Sudhi Ramamurthy

Reputation: 2478

You can patch the table row as below. This example updates row 2 (index=1) of a table that contains 4 columns. Note that index value is 0-indexed and also header row is not part of the rows collection here.

PATCH https://graph.microsoft.com/v1.0/me/drive/root:/nameditemtest.xlsx:/workbook/worksheets/sheet1/tables/Table1/rows/$/ItemAt(index=1)

{
 "values": [
        [
            "A",
            "B",
            "C",
            "D"
        ]]
}

Result: enter image description here

If you wish to patch the header row, you can patch the underlying range values property using path of PATCH ../tables/{id|name|}/rows/$/ItemAt(index={index}/headerRowRange -OR- update name property of the table column using path of PATCH ../tables/{id|name}/columns/{id}

Upvotes: 10

Related Questions