Ergwun
Ergwun

Reputation: 12978

How to read text from an Excel table range using MS Graph?

I have previously been reading the text from a table in excel using the following URL:

https://graph.microsoft.com/v1.0/me/drive/root:/my-folder%5Cmy-workbook.xlsx:/workbook/worksheets('MyWorksheet')/tables('MyTable')/range/text

Now that is giving me a 200 response with this content:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.Json"
}

I can access the range using the same URL but without the \text segment. For example the requests to the following URL

https://graph.microsoft.com/v1.0/me/drive/root:/my-folder%5Cmy-workbook.xlsx:/workbook/worksheets('MyWorksheet')/tables('MyTable')/range

result in:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#workbookRange",
    "@odata.type": "#microsoft.graph.workbookRange",
    "@odata.id": "/users('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')/drive/root/workbook/worksheets(%27%7Bxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx%7D%27)/tables(%2719%27)/range()",
    "address": "MyWorksheet!C6:BB18",
    "addressLocal": "MyWorksheet!C6:BB18",
    "cellCount": 676,
    "columnCount": 52,
    "columnHidden": false,
    "columnIndex": 2,
    "formulas": [ ... ],
    "formulasLocal": [ ... ],
    "formulasR1C1": [ ... ],
    "hidden": false,
    "numberFormat": [ ... ],
    "rowCount": 13,
    "rowHidden": false,
    "rowIndex": 5,
    "text": [
        [
            "Text",
            "From",
            "The",
            "Range",
            ...,
        ]
    ]
    "values": [ ... ],
    "valueTypes": [ ....]
}

The text property is present and contains the expected data.

The MS Graph documentation includes a text property on the range resource.

As stated above, I believe this was working earlier, so I'm assuming this is due to some bug / change / limitaion in MS Graph.

Can anyone advise how to read the text from that table range directly (and/or why I am getting that response)?

Upvotes: 1

Views: 875

Answers (1)

Marc LaFleur
Marc LaFleur

Reputation: 33114

Text is a property of the microsoft.graph.workbookRang, but not an endpoint. I'm not sure how/if /range/text could have worked in the past but I wouldn't have expected it to.

As for returning just the text, you can use the $select query parameter:

/me/drive/root:/{path}:/workbook/worksheets('{id}')/tables('{id}')/range?$select=text

Upvotes: 1

Related Questions