Hongbo Miao Hongbo Miao - 6 months ago 31
reST (reStructuredText) Question

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]
]
}

Answer Source

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}