简体   繁体   English

升级到Excel 2007 - 应用程序仍使用2003 interop

[英]Upgrade to Excel 2007 - app still uses 2003 interop

I have a windows forms application that uses excel to generate some reports. 我有一个Windows窗体应用程序,使用excel生成一些报告。 Untill now it used 2003 but i've made an upgrade to use 2007. I have installed on my machine 2003, 2007 and 2010, and my app references Microsoft.office.core, v 12.0 and microsoft.office.interop.excel v 12.0. 直到现在它使用2003年,但我已经升级到使用2007年。我已经在计算机2003、2007和2010上安装了该软件,我的应用程序引用了Microsoft.office.core,v 12.0和microsoft.office.interop.excel v 12.0 。 But in my code, when i do : 但在我的代码中,当我这样做时:

using Excel = Microsoft.Office.Interop.Excel;
......
Excel.Application excelApp = new Excel.Application();
string v = excelApp.Version;

v will be 11.0 . v将为11.0。 Also, the path references 另外,路径参考

C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\14.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll

How can this happen? 怎么会发生这种情况? Any ideea how could i fix it ? 任何想法,我该如何解决?

Thank you! 谢谢!

You shouldn't keep both versions (at least on your dev machine).On your clients machine it shouldn't be a problem . 你不应该保留这两个版本(至少在你的开发机器上)。在你的客户机器上它应该不是问题。 Normally in this situation your code should load the 2007 PIAs. 通常在这种情况下,您的代码应该加载2007 PIA。 I suggest that you should do a repair . 我建议你应该修理一下。 Or do a complete fresh install of 2007.Or fiddle wth the registry and set the active version to 12 (which I don't recommend) 或进行2007年的全新安装。或在注册表中进行调整,并将活动版本设置为12(我不建议这样做)

我最近看过这个话题,也许它对你也有用: 尝试用Excel 2007做Office Automation,但一直使用Excel 2003

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

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