interop. excel. dll on your PC, to the Windows system folder. Alternatively, some programs, notably PC games, require that the DLL file is placed in the game/application installation folder.
Yes, you are right. You need Excel to be installed to use the Excel Manipulation feature with Microsoft. Office. Interop.
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.
Microsoft.Office.Interop.Excel
.VS 2008 / 2010:
Microsoft.Office.Interop.Excel
.You can also try installing it in Visual Studio via Package Manager.
Run Install-Package Microsoft.Office.Interop.Excel
in the Package Console.
This will automatically add it as a project reference.
Use is like this:
Using Excel=Microsoft.Office.Interop.Excel;
If you have VS 2013 Express and you cant find Microsoft.Office namespace, try this ('Microsoft Excel 12.0 Object Library' if you want to use Office 2007)
Building off of Mulfix's answer, if you have Visual Studio Community 2015, try Add Reference... -> COM -> Type Libraries -> 'Microsoft Excel 15.0 Object Library'.
Instead of early binding the reference, there's an open source project called NetOffice that abstracts this from your project, making life much easier. That way you don't have to rely on your users having a specific version of Office installed.
NetOffice Codeplex site.
You have to check which version of Excel you are targeting?
If you are targeting Excel 2010 use version 14 (as per Grant's screenshot answer), Excel 2007 use version 12 . You can not support Excel 2003 using vS2012 as they do not have the correct Interop dll installed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With