MCPcopy Index your code
hub / github.com/OfficeDev/Office-Add-in-samples

github.com/OfficeDev/Office-Add-in-samples @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
49,995 symbols 124,128 edges 4,116 files 1,234 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Office Add-ins code samples

autorun-npm-audit-fix Dependabot Updates pages-build-deployment

Office Add-ins code samples are provided in this repo to help you learn, study, and build great Office Add-ins!

Getting started

The following samples show how to build the simplest Office Add-in with only a manifest, HTML web page, and a logo. They will help you understand the fundamental parts of an Office Add-in. For additional getting started information, see our quick starts and tutorials.

Task pane add-ins

Content add-ins

Completed tutorials

The following samples are the completed versions of various tutorials for Office Add-ins.

Name Description
Excel Tutorial - Completed This sample is the completed version of the Tutorial: Create an Excel task pane add-in that shows how to create an Excel add-in with a task pane and command ribbon buttons. The add-in shows how to create and sort a table, make a chart, freeze a row, protect a worksheet, and display a dialog box.
Outlook Tutorial - Completed This sample is the completed version of the Tutorial: Build a message compose Outlook add-in that shows how to build an Outlook add-in that can be used in message compose mode to insert content into the body of a message. The add-in shows how to collect information from the user, fetch data from an external service, implement a function command, implement a task pane, and display a dialog box.
PowerPoint Tutorial (Visual Studio) - Completed This sample is the completed version of the Tutorial: Create a PowerPoint task pane add-in that shows how to create a PowerPoint add-in with a task pane. The add-in shows how to add the Bing photo of the day to a slide, add text to a slide, get slide metadata, and navigate between slides.
PowerPoint Tutorial (yo office) - Completed This sample is the completed version of the Tutorial: Create a PowerPoint task pane add-in that shows how to create a PowerPoint add-in with a task pane. The add-in shows how to add an image to a slide, add text to a slide, get slide metadata, and navigate between slides.
Word Tutorial - Completed This sample is the completed version of the Tutorial: Create a Word task pane add-in that shows how to create a Word add-in with a task pane. The add-in shows how to insert and replace text ranges, paragraphs, images, HTML, tables, and content controls. The add-in also shows how to format text and how to manage content in content controls.
Office Add-in First-run Experience Tutorial - Completed This sample is the result of completing the Build an Office Add-in with a basic first-run experience that shows the basics of implementing a first-run experience (FRE). Excel is used in this sample but the pattern can be applied to other Office applications where Office Web Add-ins are supported.

Blazor WebAssembly

Name Description
Create a Blazor WebAssembly Excel add-in Uses .NET Blazor technologies to build an Excel add-in.
Create a Blazor WebAssembly Word add-in Uses .NET Blazor technologies to build a Word add-in.
Create a Blazor WebAssembly Outlook add-in Uses .NET Blazor technologies to build an Outlook add-in.

Authentication, authorization, and single sign-on (SSO)

The following samples show how to access and work with a user's Microsoft Graph data using the Microsoft identity platform.

Name Applies to Description
Office Add-in with SSO using nested app authentication Excel

PowerPoint

Word | Shows how to use MSAL.js nested app authentication (NAA) in an Office Add-in to access Microsoft Graph APIs for the signed-in user. The sample displays the signed-in user's name and email. It also inserts the names of files from the user's Microsoft OneDrive account into the document. | | Office Add-in with SSO using nested app authentication | Outlook | Shows how to use MSAL.js nested app authentication (NAA) in an Outlook Add-in to access Microsoft Graph APIs for the signed-in user. The sample displays the signed-in user's name and email. It also inserts the names of files from the user's Microsoft OneDrive account into a new message body. | | Use SSO with event-based activation in an Outlook add-in | Outlook | Shows how to use SSO to access a user's Microsoft Graph data from an event handled by an Outlook add-in. | | SSO Sample Outlook Add-in | Outlook | Uses Office's SSO feature to give the add-in access to Microsoft Graph data. | | Get OneDrive data using Microsoft Graph and MSAL.js in an Office Add-in | Excel | Builds an Office Add-in as a single-page application (SPA) with no backend. The sample uses Microsoft Graph to access workbooks stored in OneDrive for Business. Information from the workbooks is then inserted into an Office document. | | Get OneDrive data using Microsoft Graph and MSAL.NET in an Office Add-in | Excel

PowerPoint

Word | Builds an Office Add-in that uses Microsoft Graph to access workbooks stored in OneDrive for Business. Information from the workbooks is then inserted into an Office document. | | Get Excel workbooks using Microsoft Graph and MSAL in an Outlook Add-in | Outlook | Builds an Outlook add-in that connects to Microsoft Graph to access workbooks stored in OneDrive for Business. Information from the workbooks is then used to compose a new email message. | | SSO Office Add-in with ASP.NET | Excel

PowerPoint

Word |Uses the getAccessToken API in Office.js to give the add-in access to Microsoft Graph data. This sample is built on ASP.NET. | | SSO Office Add-in with Node.js | Excel

PowerPoint

Word | Uses the getAccessToken API in Office.js to give the add-in access to Microsoft Graph data. This sample is built on Node.js.|

Office

Name Description
Save custom settings in your Office Add-in Shows how to save custom settings inside an Office Add-in. The add-in stores data as key/value pairs, using the JavaScript API for Office property bag, browser cookies, web storage (localStorage and sessionStorage), or by storing the data in a hidden div in the document.
Use keyboard shortcuts for Office Add-in actions Shows how to create custom keyboard shortcuts to invoke certain actions for your Office Add-in.
Define KeyTips for the ribbon controls of an Office Add-in Shows how to define KeyTips for ribbon controls of an Office Add-in.

Outlook

Name Description
Encrypt attachments, process meeting request attendees, and react to appointment date/time changes using Outlook event-based activation Shows how to use event-based activation to encrypt attachments when added by the user. Also shows event handling for recipients changed in a meeting request, and changes to the start or end date or time in a meeting request.
Identify and tag external recipients using Outlook event-based activation Uses event-based activation to run an Outlook add-in when the user changes recipients while composing a message. The add-in also uses the appendOnSendAsync API to add a disclaimer.
Set your signature using Outlook event-based activation Uses event-based activation to run an Outlook add-in when the user creates a new message or appointment.
Verify the color categories of a message or appointment before it's sent using Smart Alerts Uses Outlook Smart Alerts to verify that required color categories are applied to a new message or appointment before it's sent.
Verify the sensitivity label of a message Uses the sensitivity label API in an event-based add-in to verify and apply the Highly Confidential sensitivity label to applicable outgoing messages.
Report spam or phishing emails in Outlook Builds an integrated spam-reporting add-in that's displayed in a prominent spot on the Outlook ribbon.
Encrypt and decrypt messages in Outlook Uses Outlook Smart Alerts and the OnMessageDecrypt event to encrypt and decrypt messages.
Invoke an Outlook add-in from an actionable message Uses an Adaptive Card in an actionable message to activate an add-in and display initialization context data.

Excel

Name Description
Create an Excel workbook from a web site with an auto-open task pane Shows how to create an Excel workbook from web site data using Node.js, and configure it so that a custom Office Add-in task pane automatically opens when the document is opened.
Data types explorer Builds an Excel add-in that allows you to create and explore data types in your workbooks. Data types enable add-in developers to organize complex data structures as objects, such as formatted number values, web images, and entity values.
Open in Teams Creates a new Excel spreadsheet in Microsoft Teams containing data you define.
Insert an external Excel file and populate it with JSON data Insert an existing template from an external Excel file into the currently open Excel file. Then retrieve data from a JSON web service and populate the template for the customer.
Create custom contextual tabs on the ribbon This sample shows how to create a custom contextual tab on the ribbon in the Office UI. The sample creates a table, and when the user moves the focus inside the table, the custom tab is displayed. When the user moves outside the table, the custom tab is hidden.
Custom function sample using web worker Shows how to use web workers in custom functions to prevent blocking the UI of your Office Add-in.
Use storage techniques to access data from an Office Add-in when offline Demonstrates how you can implement localStorage to enable limited functionality

Extension points exported contracts — how you extend this code

JQueryAjaxSettings (Interface)
* Interface for the AJAX setting that will configure the AJAX request
Samples/Office.TypeScriptAddin/Office.TypeScriptAddinWeb/Scripts/typings/jquery.d.ts
StartPageBodyProps (Interface)
(no doc)
Samples/auth/Office-Add-in-Microsoft-Graph-React/src/components/StartPageBody.tsx
IProductData (Interface)
(no doc)
Samples/excel-open-in-teams/excel-open-in-teams/Models/IProductData.cs
TrackPortType (Interface)
(no doc)
Samples/Outlook.UpsPackageTracker/UPSPackageTrackerWeb/Service References/UPS/Reference.cs
JQueryXHR (Interface)
* Interface for the jqXHR object
Samples/Office.TypeScriptAddin/Office.TypeScriptAddinWeb/Scripts/typings/jquery.d.ts
HeroListItem (Interface)
(no doc)
Samples/auth/Office-Add-in-Microsoft-Graph-React/src/components/HeroList.tsx
TrackPortTypeChannel (Interface)
(no doc)
Samples/Outlook.UpsPackageTracker/UPSPackageTrackerWeb/Service References/UPS/Reference.cs
JQueryCallback (Interface)
* Interface for the JQuery callback
Samples/Office.TypeScriptAddin/Office.TypeScriptAddinWeb/Scripts/typings/jquery.d.ts

Core symbols most depended-on inside this repo

isArray
called by 6351
Samples/Office.TypeScriptAddin/Office.TypeScriptAddinWeb/Scripts/typings/jquery.d.ts
extend
called by 5279
Samples/Office.TypeScriptAddin/Office.TypeScriptAddinWeb/Scripts/typings/jquery.d.ts
then
called by 5143
Samples/Office.TypeScriptAddin/Office.TypeScriptAddinWeb/Scripts/typings/jquery.d.ts
toArray
called by 3485
Samples/Office.TypeScriptAddin/Office.TypeScriptAddinWeb/Scripts/typings/jquery.d.ts
slice
called by 2894
Samples/Office.TypeScriptAddin/Office.TypeScriptAddinWeb/Scripts/typings/jquery.d.ts
w
called by 2545
Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/outlook-15.js
j
called by 2544
Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/office.js
N
called by 2543
Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/office.js

Shape

Function 48,174
Method 1,170
Class 534
Interface 85
Enum 32

Languages

TypeScript98%
C#2%
C++1%

Modules by API surface

Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/outlook-web-16.01.debug.js538 symbols
Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/outlook-mac-16.00.debug.js473 symbols
Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/outlook-ios-16.00.debug.js469 symbols
Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/outlook-android-16.00.debug.js469 symbols
Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/powerpoint-web-16.00.debug.js462 symbols
Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/outlook-win32-16.02.debug.js459 symbols
Samples/Outlook.MailCRM/DXDemos.Office365/Scripts/angular.js431 symbols
Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/visio-web-16.00.debug.js429 symbols
Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/onenote-mac-16.00.debug.js414 symbols
Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/onenote-ios-16.00.debug.js409 symbols
Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/onenote-winrt-16.00.debug.js407 symbols
Samples/word-add-in-get-set-edit-openxml/C#/WD_OpenXML_jsWeb/Scripts/Office/1/word-ios-16.00.debug.js406 symbols

For agents

$ claude mcp add Office-Add-in-samples \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact