C# Excel add-in examples with source code

C# Excel HowTo

The C# examples you will find further on this page work with all versions of Microsoft Excel 2021, 2019, 2016, 2013, 2010, and lower:

You may also be interested in:

Note. You can find the most recent HowTo samples on Add-in Express blog. Be sure to check it out, we add new code examples almost every week.

C# samples of Excel add-ins

How to develop a COM add-in for Microsoft Office 2021 - 2000

This example shows how to create a COM add-in for Microsoft Excel, Word and PowerPoint using Add-in Express for Office and .net. See how to add a custom ribbon, toolbar and command bar controls, create advanced task panes, handle events and more.
Download

How to build integrated Excel extensions: COM Add-in, RTD Server and XLL in one project

This C# example shows how to create integrated Excel extensions containing a plugin, real-time data server and a number of XLL add-ins (User-defined functions) in a single Visual Studio project.
Download

How to create a COM addin for Excel: commandbar and menu

This sample accompanies the following article published on our blog: How to write Excel addin using C#. Part 1 focuses on designing Excel 2003 specific UI elements and shows how create a new and customize an existing command bar, add new items to Excel main menu, etc.
Download

How to create a COM addin for Excel: custom ribbons

This project accompanies part 2 of the above mentioned article: Creating Excel addin, customizing the Ribbon. It takes a closer look at the components and tools Add-in Express provides for customizing the Excel Ribbon UI.
Download

How to create an Excel Automation add-in

This Excel Automation addin project is described on the Excel Automation add-ins page in the developer tutorial.
Download Automation addin

How to make an Excel XLL add-in using C#

This code example demonstrates how to develop an XLL addin providing a sample user-defined function allocated to a custom function category. You can find the detailed write-up of this Excel XLL add-in project in the Add-in Express Developer Manual.
Download XLL addin

How to create a custom toolbar in Excel

This example shows how to create a custom toolbar in Excel.
Download

How to create a custom context menu for Excel

See how to create a commandbar based and a ribbon based context menu for all versions of Microsoft Excel in one C# project.
Download

How to create an Excel document level add-in in C#

This is a simple implementation of a timesheet using MSForms controls.
Download

Working with Excel Object model

How to process Change, SelectionChange, and other events of the Excel Worksheet class?

This C# Excel addin shows how to use the Add-in Express Excel Worksheet Events class to process the Change event of the worksheet.
Download

How to add PivotTables and Slicers to MS Excel programmatically

This C# Excel addin demonstrates how developers can programmatically add a pivot table and slicers to a spreadsheet.
Download PivotTables and Slicers addin

How to add sparklines and charts to MS Excel programmatically

Excel charts and sparklines enable Microsoft Office developers to provide users with more ways to visualize their data. This sample explains how you can programmatically add sparklines and charts to Microsoft Excel.
Download Sparklines and Charts add-in

How to import contacts and appointments from Excel into Outlook and vice-versa

This code example demonstrates how to write a shared C# Excel and Outlook add-in to import and export data from Excel to Outlook and in the reverse direction.
Download Excel to Outlook Exporter addin

How to import data from SQL databases and other sources to Excel

C# Excel add-in demos how to import SQL server and text file data into Excel using the Excel Object model and Add-in Express for Office and .net.
Download Importing Excel Data add-in

How to work with Excel cell values, formulas and formatting

This c-sharp example shows how to manipulate cells in your Excel add-ins: how to retrieve multiple cells or selected cells, set cell formulas, display the Insert Function dialog and change cell formatting.
Download Excel Cell Format add-in

Advanced Excel task panes

How to make an Excel task pane visible / invisible programmatically

This Excel C# add-in demonstrates how to display your custom Advanced Excel Task Pane (ADXExcelTaskPane) using a command bar button, or how to prevent the task pane from being shown in Excel.
Download

How to interact with several Advanced Excel Task Panes in one layout position

This C# Excel plugin shows how you can interact with several Excel task panes in one position. Click on a RadioButton control on the Controlling Task Pane to activate the needed ADXExcelTaskPane.
Download

How to develop a context-dependent Excel task pane

The sample plugin for Excel shows how to dynamically show and hide an Advanced Excel Task Pane depending on whether cell A1 contains some string or doesn't.
Download

Excel RTD server

How to use dbs as a data source for RTD Servers

This RTD server project demonstrates how to use System.Data.DataSet and System.Data.DataTable as a data source for real-time data servers. Also see watch a video tutorial on Programming RTD servers.
Download

How to build Excel Real-Time Data servers

This is the code sample for the RTD server project described in our developer tutorial.
Download RTD server