以编程方式识别Excel版本 [英] Identifying Excel version programmatically

查看:58
本文介绍了以编程方式识别Excel版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的VB.NET(3.5)应用程序生成Excel报告.

My VB.NET (3.5) application generates Excel reports.

较新版本的Excel支持 Office打开XML 文件格式,而旧版本则没有.

Newer versions of Excel support the Office Open XML file format, while older versions don't.

我希望我的应用程序识别本地计算机上安装了哪个版本的Excel,并使用另一种方法来生成报告(较新版本:通过生成XML文件;较旧版本:通过利用Excel Automation).

I'd like my application to identify which version of Excel is installed on the local machine, and use a different method for generating the report (Newer versions: by generating an XML file. Older versions: by utilizing Excel Automation).

如何识别本地计算机上安装的Excel版本?

How can I identify the Excel version installed on the local machine?

推荐答案

您可以查看以下注册表项之一:

You can have a look at one of the following registry keys :

HKEY_USERS\.DEFAULT\Software\Microsoft\Office\11.0\Excel 
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel

您应该查找包含"Excel"的键的存在,因为您可以安装Office 2003和visio 2007,所以两个键都将存在,但是只有一个具有Excel子键:

You should look for the existence of the key, with "Excel" in it, as you can have office 2003 installed, and visio 2007 aside, so both keys will exist, but only one will have an Excel subkey :

HKEY_CURRENT_USER\Software\Microsoft\Office\11.0
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0

编号/版本对应

  • Office 9:Office 2000
  • Office 10:Office XP(支持XML格式工作表的第一个版本)
  • Office 11:Office 2003
  • Office 12:Office 2007
  • Office 14:Office 2010(有趣的是,跳过了13个)

这篇关于以编程方式识别Excel版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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