By Robert Ellison. Updated on Sunday, September 18, 2022.
I needed a console app that reads some inputs from an online Excel workbook, does some processing and then writes back the results to a different worksheet. Because I enjoy pain I decided to use the thinly documented new Microsoft.Graph client library. The sample code below assumes that you have a work or education Office 365 subscription.
Paste the code into a new console project and then follow the instructions at the top to add the necessary NuGet packages. You'll also need to register an application at https://portal.azure.com/. You want a Native application and you'll need the Application ID and the redirect URL (just make up some non-routable URL for this). Under Required Permissions for the app you should add read and write files delegated permissions for the Microsoft Graph API.
Hope this saves you a few hours. Comment below if you need a more detailed explanation for any of the above.
(Published to the Fediverse as:
Reading and Writing Office 365 Excel from a Console app using the Microsoft.Graph C# Client API #code#microsoft#excel#graph#office365 How to read and write data to an Office 365 Excel workbook using the Microsoft.Graph client library from a C# console application.)
All comments are moderated. Your email address is used to display a Gravatar
and optionally for notification of new comments and to sign up for the newsletter.
Add Comment
All comments are moderated. Your email address is used to display a Gravatar and optionally for notification of new comments and to sign up for the newsletter.