Is there any Graph api to append row to excel worksheet?

ffbld01@uk.ibm.com 96 Reputation points
2022-04-13T11:58:26.64+00:00

We see that there is an API to append row to table in excel, but we were not able to find any API which allows us to add row to any excel worksheet without specifying its range. I know with range API we can add/update the row in excel worksheet but that API requires me to pass cell range, but what if I don't know whats the empty cell range in excel file and I just want to add a new row to any existing worksheet, is there any API for that?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,515 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. JanardhanaVedham-MSFT 3,536 Reputation points
    2022-04-13T17:54:22.817+00:00

    Hi @ffbld01@uk.ibm.com ,

    There is Microsoft Graph Create TableRow API to adds rows to the end of a table in an excel workbook or worksheet. Please note that this API can accept multiple rows of data. Adding one row at a time can affect performance. The recommended approach is to batch the rows together in a single call rather than inserting single rows.

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

    **Documentation Reference ** :
    https://learn.microsoft.com/en-us/graph/api/worksheet-post-tables?view=graph-rest-1.0
    https://learn.microsoft.com/en-us/graph/api/table-post-rows?view=graph-rest-1.0&tabs=http

    Tables creation is required to use above API for adding rows to a table in an excel sheet. Currently there is no Microsoft Graph API available to add/update the rows in an excel worksheet resource without tables creation and below microsoft documentation covers the currently supported methods/APIs for an excel worksheet resource type.

    https://learn.microsoft.com/en-us/graph/api/resources/worksheet?view=graph-rest-1.0#methods

    You can submit this feature request idea using this support link, which will be monitored by Microsoft team and make the enhancements to Microsoft Graph APIs. I will also upvote for you.

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have any further questions about this answer, please click "Comment".

    1 person found this answer helpful.
    0 comments No comments

  2. ffbld01@uk.ibm.com 96 Reputation points
    2022-04-13T18:25:37.503+00:00

    Thank you for the quick answer @JanardhanaVedham-MSFT , but we already knew about these APIs. As you can see in all the above APIs suggested by you, they all are taking table_id as one of the URL parameters. But my question is about appending rows directly in the raw worksheets which do not have any existing table in them. I will really appreciate it if you could point to any API that allows us to append rows to worksheets.