在c#中创建excel加载项时初始化加载项应用程序 [英] Initilizing Add-in Application when creating excel add-in in c#

查看:218
本文介绍了在c#中创建excel加载项时初始化加载项应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Office 2010创建一个Excel加载项。之前我在Visual Studio 2010中执行代码,在ThisAddIn_Startup上使用.net framework 3.5



private void ThisAddIn_Startup(object sender,System.EventArgs e)

{

this.Application =(Excel.Application)Microsoft.Office.Tools.Excel。

ExcelLocale1033Proxy.Wrap(typeof(Excel.Application),this.Application);



CreateCommandBar();

}

但是现在项目转移到.net framework 4.0然后ExcelLocale1033Proxy在这里已经过时了。



我应该在这里使用什么?请指导。

I am creating an Excel Add-Ins for Office 2010. Earlier i was doing code in Visual Studio 2010, .net framework 3.5 on ThisAddIn_Startup like

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application = (Excel.Application)Microsoft.Office.Tools.Excel.
ExcelLocale1033Proxy.Wrap(typeof(Excel.Application), this.Application);

CreateCommandBar();
}
But now the project is shifted on .net framework 4.0 then ExcelLocale1033Proxy is obsolete here.

What should i use here? Please guide.

推荐答案

不幸的是,你将不得不放弃ExcelLocale1033Proxy。



项目通过使用Microsoft Office System的Microsoft Visual Studio 2005工具创建使用Microsoft.Office.Tools.Excel.ExcelLocale1033Proxy类实例化Excel Microsoft.Office.Interop.Excel.Application对象。此类已从用于Office运行时的Visual Studio 2010工具部分中删除,该部分用于面向.NET Framework 4或.NET Framework 4.5的解决方案。因此,您必须删除或注释掉引用此类的代码行。



我们必须删除ExcelLocale1033Proxy才能初始化应用程序。没有必要在.net framework 4.0及更高版本的升级框架中执行此操作。这已经初始化了。



参考:http://msdn.microsoft.com/en-us/library/vstudio/ee712587.aspx
Unfortunately, you will have to let go of ExcelLocale1033Proxy.

Projects that were created by using Microsoft Visual Studio 2005 Tools for the Microsoft Office System instantiate the Excel Microsoft.Office.Interop.Excel.Application object by using the Microsoft.Office.Tools.Excel.ExcelLocale1033Proxy class. This class has been removed from the portion of the Visual Studio 2010 Tools for Office Runtime that’s used for solutions that target the .NET Framework 4 or the .NET Framework 4.5. Therefore, you must remove or comment out the line of code that references this class.

Just we have to remove ExcelLocale1033Proxy to initialize the Application. There is no need to do this in upgraded framework like .net framework 4.0 and above. This is already initialized.

Reference : http://msdn.microsoft.com/en-us/library/vstudio/ee712587.aspx


这篇关于在c#中创建excel加载项时初始化加载项应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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