How to reference Microsoft.Office.Interop.Excel dll?
Use NuGet (VS 2013+):
The easiest way in any recent version of Visual Studio is to just use the NuGet package manager. (Even VS2013, with the NuGet Package Manager for Visual Studio 2013 extension.)
Right-click on "References" and choose "Manage NuGet Packages...", then just search for Excel.
VS 2012:
Older versions of VS didn't have access to NuGet.
- Right-click on "References" and select "Add Reference".
- Select "Extensions" on the left.
- Look for
Microsoft.Office.Interop.Excel
.
(Note that you can just type "excel" into the search box in the upper-right corner.)
VS 2008 / 2010:
- Right-click on "References" and select "Add Reference".
- Select the ".NET" tab.
- Look for
Microsoft.Office.Interop.Excel
.
Microsoft.Office.Interop.Excel Reference Cannot be found
As described in http://social.msdn.microsoft.com/Forums/vstudio/en-US/c9e83756-4ae2-4ed4-b154-1537f3bb3a22/cant-find-microsoftofficeinteropexceldll?forum=netfxsetup
On the Project menu, click "Add Reference."
On the COM tab, click Microsoft Excel Object Library, and then click Select. In Visual Studio 2012, locate Microsoft Excel 14.0 (or other version) Object Library on the COM tab.
Click OK in the Add References dialog box to accept your selections. If you are prompted to generate wrappers for the libraries that you selected, click “Yes”.
What reference do I need to use Microsoft.Office.Interop.Excel in .NET?
Update (thanks user2347528)
These assemblies are available as NuGet packages, which is much easier than my original answer.
You can install by either right clicking on References in your project and selecting Manage NuGet packages... and searching for one of the packages listed below, or install using the Package Manager Console:
PM> Install-Package Microsoft.Office.Interop.Excel
- Microsoft.Office.Interop.Excel
- Microsoft.Office.Interop.Word
- Microsoft.Office.Interop.Outlook
- Microsoft.Office.Interop.PowerPoint
- Microsoft.Office.Interop.Graph
These are available as "Primary Interop Assemblies", which can be installed with Office, or downloaded and installed separately. How to: Install Office Primary Interop Assemblies.
Once those are installed, you can reference them in your project in the Add Reference dialog, under .NET. If you do not see those Microsoft.Office.Interop assemblies listed, then they have not been installed yet. Install them from your setup, or download and install them separately (see my link above for the downloads).
adding Microsoft.Office.Interop.Excel reference
I see a copy under C:\Windows\assembly\GAC_MSIL. Is it there for you?
If that doesn't work, open Windows Command Processor and use
dir /s microsoft.office.interop.excel.*
Can't get Microsoft.Office.Interop reference to work
You need to add the library assembly reference to your project.
They are referred to as "Primary Interop Assemblies".
(Assuming Visual Studio 2010)
Procedure
- open the solution explorer window
- expand your project folder accordion.
- right click on the references element
- select "add reference" from the dropdown
- select the .NET tab and look for the object library called
Microsoft.Office.Interop.Excel
. - click ok
The object library should now appear in your references.
Microsoft.Office.Interop.Excel Reference in Build Server
You need to have MS Excel installed on the build server also. Interop DLL cannot function without Excel itself being present.
For more details on Office development, you can refer the official documentation on MSDN.
Related Topics
What Method in the String Class Returns Only the First N Characters
Date Format Yyyy-Mm-Ddthh:Mm:Ssz
Advantages to Using Private Static Methods
Query String Not Working While Using Attribute Routing
Display Progress Bar While Doing Some Work in C#
Observablecollection and Item Propertychanged
What Does Default(Object); Do in C#
How to Implement Gzip Compression in ASP.NET
.Net - Convert Generic Collection to Datatable
Deferred Execution and Eager Evaluation
How to Align Text in Columns Using Console.Writeline
Expression.Lambda and Query Generation at Runtime, Simplest "Where" Example
How to Use Shell32 Within a C# Application
How to Prevent Flickering in Listview When Updating a Single Listviewitem's Text
Using Datetime in a SQLparameter for Stored Procedure, Format Error