Skip to content

Instantly share code, notes, and snippets.

@venkyvb
Last active July 31, 2020 16:26
Show Gist options
  • Save venkyvb/8167b5aff96f9e6a0624bc143f5c46ca to your computer and use it in GitHub Desktop.
Save venkyvb/8167b5aff96f9e6a0624bc143f5c46ca to your computer and use it in GitHub Desktop.
Using Microsoft Graph Excel API for calculations

Steps done using Graph Explorer - https://developer.microsoft.com/en-us/graph/graph-explorer

  1. Create a new non-persistent session for the workbook
POST
https://graph.microsoft.com/v1.0/me/drive/items/{itemId}/workbook/createSession

{
    "persistChanges": false
}
  1. Use the session as HTTP header (in all the subsequent calls)
"workbook-session-id": "<non-persistent-session-id>"
  1. Send Input values - note in this case we are just updated a single input cell, this can be a range e.g. C3:C7 well, in which case the values would be [["valC3", "valC4", "valC5", "valC6", "valC7"]]. Also number format can be specified using the attribute e.g. "numberFormat" for each cell.
PATCH
https://graph.microsoft.com/v1.0/me/drive/items/{itemId}/workbook/worksheets('InputOutput')/range(address='C3')

{
    "values" : [["230"]]
}
  1. Read the output values
GET
https://graph.microsoft.com/v1.0/me/drive/items/{itemId}/workbook/worksheets('InputOutput')/range(address='C9:C11')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment