简体   繁体   English

VB.net VS2008中的Excel APp

[英]Excel APp in VB.net VS2008

I am creating a excel application in VB.net using VisualStudio 2008. 我正在使用VisualStudio 2008在VB.net中创建一个excel应用程序。

while adding reference Microsoft.office.interop.excel we have both managed ( On the .NET TAB) and unmanaged (on the COM TAB). 在添加参考Microsoft.office.interop.excel时,我们同时管理(在.NET TAB上)和非托管(在COM TAB上)。

currently i am referencing the COM tab but it is not showing the errors properly. 目前,我正在引用“ COM”选项卡,但未正确显示错误。

can i use the excel interop on .NET tab? 我可以在.NET选项卡上使用Excel互操作吗?

which one is the better way to reference and what is the difference between those two? 哪一种是更好的引用方式,两者之间有什么区别?

Yes, do use the .NET interop library to create the namespace 'Microsoft.Office.Interop.Excel' 是的,请使用.NET互操作库创建命名空间“ Microsoft.Office.Interop.Excel”

Then define an application object with 然后用定义一个应用对象

Private app As Microsoft.Office.Interop.Excel.Application

and either a) connect to an a running Excel application with 或a)使用以下命令连接到正在运行的Excel应用程序

app = CType(GetObject([Class]:="Excel.Application"), Microsoft.Office.Interop.Excel.Application)

or b) create a new Excel application with 或b)使用以下命令创建一个新的Excel应用程序

app = CType(CreateObject(ProgId:="Excel.Application"), Microsoft.Office.Interop.Excel.Application)

Good luck! 祝好运!

The .NET version of the Interop library is basically the COM component in a .NET wrapper. Interop库的.NET版本基本上是.NET包装程序中的COM组件。 It is advisable to use the .NET implementation. 建议使用.NET实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM