一个excel VSTO加载项可以与excel 2007和2010兼容吗? [英] Can an excel VSTO add-in be compatible with excel 2007 and 2010?

查看:140
本文介绍了一个excel VSTO加载项可以与excel 2007和2010兼容吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用可以部署到excel 2007和2010的VSTO开发一个excel加载项?



有关此主题的详细资源的任何链接也不会感激 - 我似乎没有找到任何具体地解决这个问题的谷歌。



我正在使用Visual Studio 2010开发一个C#excel加载项。我已经回答这个 for Word,但它也适用于Excel:



如果要部署到Office 2010和2007,则必须添加对 v12.0的引用程序集( Microsoft.Office.Interop.Excel Office



现在还有您的插件将需要2007 PIA的问题,但如果您仅在目标机器上安装Office 2010(因为它们以Office 2007为先决条件),则不会进行安装。
要解决这个问题,您必须为这两个dll(参考属性)设置 Embed Interop Assemblies = true ,并使用 dynamic 您不能直接引用的类型。



这会导致Intellisense无法找到方法等的奇怪,但不应该是一个大问题 - 至少现在,PIA不再需要,您的加载项将在2007和2010年部署(您也必须关心安装程序,但这是一个完整的其他故事)。



这有点麻烦,但是如果你正在使用VSTO,我想你习惯了这种东西: - )


Is it possible to develop an excel add-in using VSTO that can be deployed to both excel 2007 and 2010?

Any links to a detailed resource on this topic would also be appreciated - I can't seem to find anything on google that specifically addresses this question.

I am developing a C# excel add-in using Visual Studio 2010.

解决方案

I already answered this for Word, but it also applies to Excel:

If you want to deploy to Office 2010 AND 2007, you have to add references to the v12.0 assemblies (Microsoft.Office.Interop.Excel and Office).

Now there is still the problem that your addin will require the 2007 PIA, but they won't install if you only have Office 2010 on the target machine (because they have Office 2007 as a prerequisite). To solve this you have to set Embed Interop Assemblies = true for those two dlls (in the reference properties) and use dynamic for the types you can't directly reference anymore.

This causes some "weirdness" with Intellisense not finding methods etc., but it should not be a big problem -at least now PIA are not required anymore and your addin will deploy on both 2007 and 2010 (you'll have to take care of the installer as well, but that is a whole other story).

It's a bit of a mess, but if you are working with VSTO I suppose you are used to this kind of stuff :-)

这篇关于一个excel VSTO加载项可以与excel 2007和2010兼容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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