Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Latest commit

 

History

History
139 lines (89 loc) · 5.14 KB

README.md

File metadata and controls

139 lines (89 loc) · 5.14 KB

Microsoft Graph Search API Sample for Excel AddIn (.NET)

Table of contents

Introduction

This sample will show you how to implement an Excel AddIn that makes a call to the Microsoft Graph Search API endpoint and then display the results in a workbook.

Prerequisites

This sample requires the following:

Getting started with the sample

  1. Download or clone this repo.

Configure Azure

Follow the steps in Configuring Azure.

Configure the project

  1. Open the Sample2.1/ExcelWebAddIn1/GraphSearchApiExcel.sln solution with Visual Studio
  2. In the GraphSearchApiExcelWeb project, open the web.config file
  3. Replace the values for the following:
  • ida:TenantId - your Azure AD Tenant ID
  • ida:ClientId- the client id from the Configuring Azure steps
  • ida:Password - the client secret from the Configuring Azure steps

Update the AddIn xml

  1. Open the GraphSearchApiExcel.xml file
  2. Scroll to the bottom of the file, in the WebApplicationInfo section, ensure that the clientid matches the client id from the configuration steps above.

Enter your application id and the uri

  1. Save the file

Create a File Share

  1. On your development machine, create a folder called c:\manifests
  2. Right-click the folder, select Properties
  3. Click the Sharing tab
  4. Click Share

Create a Share

  1. Enter your account name, click Share
  2. Close the dialog
  3. Copy the GraphSearchApiExcel.xml file you edited above to the new manifests share

Register the AddIn Fileshare with Office

  1. Open Excel
  2. Select Blank Workbook

Create a blank workbook

  1. Click File->Options
  2. Select the Trust Center tab
  3. Click the Trust Center Settings button

Open the trust center

  1. Select the Trusted Add-in Catalogs tab
  2. In the catalog url, type //localhost/manifests, then click Add catalog

Add a trusted catalog location

  1. Click OK and close out all dialogs

Register the AddIn with Excel

  1. In the ribbon, select the Insert tab
  2. Click Get Add-ins

Add an AddIn

  1. Select SHARED FOLDER, the select the Microsoft Graph Search Add-in
  2. Click Add

Add the Graph AddIn

  1. Close the AddIn window
  2. Click the Home tab
  3. You should now have a new ribbon item in a group called Search and a button called Graph Search API
  4. Click the button, you should the task pane open with error:

Explore the AddIn

Test the AddIn

  1. Switch back to Visual Studio
  2. Right-click the GraphSearchApiExcelWeb project, select Debug->Start new instance
  3. Switch back to Excel, click Retry to refresh the application task pane.
  4. Run a search
  5. Review the results that are exported to the workbook sheet as a filterable and searchable table

Code of note

  • The GraphController.cs file is responsible for trading the identity token for a graph token.
  • The Home.js file contains a method called parseResult that will dynamically create an Excel table based on the columns returned from the search result.

Questions and comments

We'd love to get your feedback about this sample! Please send us your questions and suggestions in the Issues section of this repository.

Your feedback is important to us. Connect with us on Stack Overflow. Tag your questions with [MicrosoftGraph].

Contributing

If you'd like to contribute to this sample, see CONTRIBUTING.md.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Additional resources

Copyright

Copyright (c) 2019 Microsoft. All rights reserved.