I use the Microsoft Graph SDK and try to read the content of an Excel file within a MS Teams Channel.
I am able to retrieve the UsedRange of the worksheet that I want to read from. I do this with the following call:
var usedRangeWorksheetDetails = await _graphServiceClient
.Drives[teamsChannelDriveId]
.Items[driveItemExcelFile.Id]
.Workbook
.Worksheets["Details"]
.UsedRange
.GetAsync(cancellationToken: cancellationToken)
.ConfigureAwait(false);
When I inspect the UsedRange object returned from this call in the debugger, I see it correctly identified the cells that hold values, e.g. it shows a column count of 45 and a row count of 25, and the address of the range is Details!A1:AS25
How do I get from here to the actual cell data? I see a property called Values which is of type Microsoft.Graph.Models.Json
but I have no idea how to use this.
If I run the equivalent of my SDK call in the Graph Explorer with the following URL:
https://graph.microsoft.com/v1.0/drives/[teamsChannelDriveId]/items/[driveItemExcelFileId]/workbook/worksheets/Details/UsedRange and look in the Response Preview I see a JSON including a field called values
that holds the cell data. So I expect the same must be possible using the SDK, but what am I missing here?
This is the main issue in SDK v5 for almost one year. Code for SDK is auto-generated, but the generator doesn't have support for untyped JSON represented by
Microsoft.Graph.Models.Json
.Currently, an enhancement is in progress, but no exact ETA.
Issues:
https://github.com/microsoft/kiota/issues/2319
https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/1783
https://github.com/microsoft/kiota/issues/3007
You can try to read all discussions on GitHub, maybe there will be some workaround mentioned. If you can, leave a comment on GitHub, so the Graph team is motivated to resolve it.