Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Microsoft Graph Excel REST API ASP.NET Excel as a Calculation Service

This sample shows how to call a custom Excel function within an Excel document stored in your OneDrive for Business acccount using the Excel REST APIs.


To use the Microsoft Graph Excel REST API ASP.NET Excel as a Calculation Service, you need the following:

  • Visual Studio 2015 installed and working on your development computer.

    Note: This sample is written using Visual Studio 2015. If you're using Visual Studio 2013, make sure to change the compiler language version to 5 in the Web.config file: compilerOptions="/langversion:5

  • A Microsoft Office 365 account. You can sign up for an Office 365 Developer subscription that includes the resources that you need to start building apps.

    Note: If you already have a subscription, the previous link sends you to a page with the message Sorry, you can’t add that to your current account. In that case, use an account from your current Office 365 subscription.

  • A Microsoft Azure Tenant to register your application. Azure Active Directory (AD) provides identity services that applications use for authentication and authorization. A trial subscription can be acquired here: Microsoft Azure.

    Important: You also need to make sure your Azure subscription is bound to your Office 365 tenant. To do this, see the Active Directory team's blog post, Creating and Managing Multiple Windows Azure Active Directories. The section Adding a new directory will explain how to do this. You can also see Set up your Office 365 development environment and the section Associate your Office 365 account with Azure AD to create and manage apps for more information.

  • The client ID and redirect URI values of an application registered in Azure. This sample application must be granted the Have full access to user files and files shared with user permission for Microsoft Graph. Add a web application in Azure and grant the proper permissions to it:

    • In the Azure Management Portal, select the Active Directory tab and an Office 365 tenant.
    • Select the Applications tab and choose the application that you want to configure.
    • In the permissions to other applications section, add the Microsoft Graph application.
    • For the Microsoft Graph application, add the following delegated permissions: Have full access to user files, read and write access to user profile and sign in to user profile.
    • Save the changes.

    Note: During the app registration process, make sure to specify http://localhost:44347 as the Sign-on URL and the Reply URL.

Configure the app

  1. Open ExcelWorkbookAsACalculationService.sln file.
  2. In Solution Explorer, open the Web.config file.
  3. Replace ENTER_YOUR_CLIENT_ID with the client ID of your registered Azure application.
  4. Replace ENTER_YOUR_SECRET with the key of your registered Azure application.

Run the app

  1. Press F5 to build and debug. Run the solution and sign in with your organizational account. The application launches on your local host and shows the starter page.

    Note: Copy and paste the start page URL address http://localhost:44391/home/index to a different browser if you get the following error during sign in: AADSTS70001: Application with identifier ad533dcf-ccad-469a-abed-acd1c8cc0d7d was not found in the directory.

  2. Select the Excel link from the top menu bar.
  3. The application relies on you having an Excel workbook called 'RestaurantBillCalculator.xlsx' in the root OneDrive folder of your O365 account. If this file does not exist, it will be automatically added to your OneDrive
  4. On calculate page enter the appropriate values and press the calculate button - the total bill (including tip) and amount per person should be calculated.


Uses the Microsoft Graph Excel REST API to call an Excel Workbook / Worksheet calculation




No releases published


No packages published
You can’t perform that action at this time.