Microsoft.Office.Interop.Excel Reference Cannot be found

社会主义新天地 提交于 2021-01-21 06:21:08

问题


I am having troubles adding the excel reference to my project. I have already installed Primary Interop Assemblies.

The project is detecting the Microsoft.Office.Interop.Word assembly reference correctly but the excel reference still cannot be found.

When I try to manually add the reference, I right click the project, add reference, navigate to the Microsoft.Office.Interop.Excel file and try to add it manually. Once i select the reference I then make sure the reference is checked, then hit ok. Nothing happens, it fails to actually add the reference path to the project.

Using VS2012 Ultimate.

Any suggestions on what I can do to get the project to see the excel reference?


回答1:


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”.




回答2:


If you don't have excel installed, run this command in the nuget-packet-manager-console:

Install-Package Microsoft.Office.Interop.Excel



回答3:


I installed Microsoft office PIAs, but I had the same problem, cannot find microsoft.office.interop.excel dll, I also I installed Visual Studio 2010 Tools for the Office System 4.0 Runtime Service Pack 1 but still the problem persist.

Finally I resolve the problem with an add of Office / SharePoint development package to my Visual Studio 2017 installation:

Go to Tools > Get Tools and Features ..

And then check Office / sharepoint development and modify your installation.




回答4:


I installed MS Office 13 and from then on I started getting this error in VS 2012 project. I tried adding the MS Office lib via COM control but that didnt work. Finally I had to add this library references from the "Extensions" section (not not under COM); had to select Microsoft.Office.Interop.Excel, version 15.0.0.0. That fixed the error.

Hope that helps some.



来源:https://stackoverflow.com/questions/19543279/microsoft-office-interop-excel-reference-cannot-be-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!