C#项目不请参阅Excel COM参考 [英] C# project does not see Excel COM Reference

查看:216
本文介绍了C#项目不请参阅Excel COM参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写使用Visual Studio 2010前preSS版的应用程序。我在使用Excel自动化的问题。我添加了一个COM引用到Microsoft Excel 12.0对象库。它补充以下参考资料:

im writing an application using Visual Studio 2010 Express Edition. I have a problem using Excel Automation. I added a COM Reference to Microsoft Excel 12.0 Object Library. It added following References:

Microsoft.Office.Core
Microsoft.Office.Interop.Excel 
VBIDE

我还添加了使用条款:

I also added a using clause:

using Microsoft.Office.Interop.Excel;

然后我从一个微软

m_objExcel = new Excel.Application();
m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
m_objBook = (Excel._Workbook)(m_objBooks.Add(m_objOpt));

和它强调Excel和呼喊:

and it underlines Excel and shouts:

类型或命名空间名称'Excel的'
  找不到(是否缺少
  使用指令或程序集
  引用?)

The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)

我的Office 2007专业增强版和互通.NET 2.0 Microsoft窗体组件的(不好意思,从波兰语翻译)安装。目标框架是.NET 4的客户端配置文件。

I have Office 2007 Professional Plus and the "Interoperability component for .net 2.0 Microsoft Forms" (sorry, translation from polish) installed. Target Framework is .NET 4 Client Profile.

任何想法可能是错的?

推荐答案

试着改变你的使用来:

using Excel = Microsoft.Office.Interop.Excel;

这样 Excel中将是完整的命名空间的别名,其中code其余似乎期待。

That way Excel will be an alias for the full namespace, which the rest of the code seems to expect.

这篇关于C#项目不请参阅Excel COM参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆