Home > Net >  Create table in sharepoint excel file using REST API?
Create table in sharepoint excel file using REST API?

Time:10-22

I am trying to create a table given a range of cells in a Sharepoint Excel file.

For this purpose I'm consulting Microsoft Graph REST API documentation in this link

However, when I try to create the table, I see that the request for "Create table" is a bit weird as it does not specify the worksheet nor the range from which I want to create the table...

Any ideas how to do this? Thank you

CodePudding user response:

According to the documentation the request body has property address where the range and optional sheet name is specified.

Endpoints:

POST /me/drive/items/{id}/workbook/tables/add
POST /me/drive/root:/{item-path}:/workbook/tables/add
POST /me/drive/items/{id}/workbook/worksheets/{id|name}/tables/add
POST /me/drive/root:/{item-path}:/workbook/worksheets/{id|name}/tables/add

Request body:

{
  "address": "Sheet1!A1:D5",
  "hasHeaders": true
}

The example you are referencing is really weird and probably wrong (endpoint POST https://graph.microsoft.com/v1.0/me/drive/items/{item-id}/workbook/tables/{table-id}/add is wrong. You don't know the table id before creation and the request body is also wrong).

Resources:

Create table

  • Related