C# 找不到 Microsoft.Office.Interop.Excel 参考
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19543279/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Microsoft.Office.Interop.Excel Reference Cannot be found
提问by stylex
I am having troubles adding the excel reference to my project. I have already installed Primary Interop Assemblies.
我在将 excel 引用添加到我的项目时遇到了麻烦。我已经安装了主互操作程序集。
The project is detecting the Microsoft.Office.Interop.Word assembly reference correctly but the excel reference still cannot be found.
该项目正在正确检测 Microsoft.Office.Interop.Word 程序集引用,但仍然找不到 excel 引用。
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.
当我尝试手动添加引用时,我右键单击项目,添加引用,导航到 Microsoft.Office.Interop.Excel 文件并尝试手动添加它。一旦我选择了参考,我就会确保参考被选中,然后点击确定。什么也没有发生,它实际上无法将引用路径添加到项目中。
Using VS2012 Ultimate.
使用 VS2012 Ultimate。
Any suggestions on what I can do to get the project to see the excel reference?
关于我可以做些什么来让项目看到 excel 参考的任何建议?
采纳答案by Big EMPin
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”.
在“项目”菜单上,单击“添加引用”。
在 COM 选项卡上,单击 Microsoft Excel 对象库,然后单击选择。在 Visual Studio 2012 中,在 COM 选项卡上找到 Microsoft Excel 14.0(或其他版本)对象库。
单击“添加引用”对话框中的“确定”以接受您的选择。如果系统提示您为所选库生成包装器,请单击“是”。
回答by Yoda
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.
我安装了 MS Office 13,从那时起我开始在 VS 2012 项目中收到此错误。我尝试通过 COM 控件添加 MS Office 库,但这没有用。最后,我不得不从“扩展”部分(不在 COM 下)添加这个库引用;必须选择 Microsoft.Office.Interop.Excel,版本 15.0.0.0。这修复了错误。
Hope that helps some.
希望能帮到一些人。
回答by Luca Ziegler
If you don't have excel installed, run this command in the nuget-packet-manager-console:
如果您没有安装 excel,请在 nuget-packet-manager-console 中运行此命令:
Install-Package Microsoft.Office.Interop.Excel
回答by ELKALAKHI Mohammed
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.
我安装了 Microsoft Office PIA,但遇到了同样的问题,找不到 microsoft.office.interop.excel dll,我也安装了 Visual Studio 2010 Tools for the Office System 4.0 Runtime Service Pack 1 但问题仍然存在。
Finally I resolve the problem with an add of Office / SharePoint development package to my Visual Studio 2017 installation:
最后,我通过将 Office / SharePoint 开发包添加到我的 Visual Studio 2017 安装中解决了该问题:
Go to Tools > Get Tools and Features ..
转到工具 > 获取工具和功能..
And then check Office / sharepoint development and modify your installation.
然后检查 Office/sharepoint 开发并修改您的安装。