未安装相应Office版本如何获取特定Excel对象库
我正在开发一个 Excel 自动化应用程序,可以读取和写入 Excel 电子表格。我的计算机上安装了 Office 2007。因此,我可以参考 Excel 12.0 对象库和 Excel 5.0 对象库。我不想使用 Excel 5.0,因为它确实很旧并且文档很少。因此我引用的是 Excel 12.0。
但是目标计算机安装了 Office 2003,因此只有 Excel 11.0。因此,当我编译程序时,它会在目标计算机上崩溃,因为引用的库不同。
我想知道有没有办法可以在不安装 Office 03 的情况下获取 Excel 11.0?我尝试从 msdn 和 microsoft 支持页面查找答案,但找不到任何内容?这很奇怪,因为将来也可能发生这种情况,即开发人员拥有比客户端更新版本的 Office?
I am developing a Excel automation app that read and write to Excel spreadsheet. I have Office 2007 installed on my machine. I therefore can reference the Excel 12.0 Object Library and the Excel 5.0 Object Library. I don't want to use Excel 5.0 because it's really quite old and poorly documented. Therefore I'm referencing Excel 12.0.
However the target machine have Office 2003 installed and therefore only have Excel 11.0. So when I compile my program it crashes on the target machine since the referenced library are different.
I was wondering is there a way I could obtain the Excel 11.0 without installing Office 03? I tried to find answers from msdn and microsoft support page but couldn't find anything? This is quite strange since it could also happen in the future where developers has newer editions of Office than clients?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看我的开源项目 MS Office Wrapper for .NET。
Office 应用程序对象的实例是通过“CreateObject”方法动态创建的,然后使用后期绑定功能,因此您不需要对任何版本的 MS Office 库进行任何“强引用”。
您可以使用 C#、VB.NET、J# 等...
源代码也可用。
Look at my open source project MS Office Wrapper for .NET.
The instance of Office application object is created dynamically via "CreateObject" method and then is used late-binding ability, so you don't need any "strong reference" to any version of MS Office libraries.
You can use C#, VB.NET, J#, etc...
The source code is available too.
其实你没必要战斗得那么坚强。只需包含到最新的 Office PIA (2007) 分发包中即可。它向后兼容 Office 2003。
请阅读 Excel 产品团队博客< /a> 和有关兼容性的详细答案
我们将 2007 PIA 纳入发行版,并且在使用以前的 (2003) 版本的 Excel 时没有任何问题。
这里提到的 MS Office Wrapper for .NET 是非常好的替代方案。
You don't really have to fight so strong. Just include into distribution package latest Office PIA (2007). It backward compatible with Office 2003.
Please read Excel product team blog and detailed answer about compatibility here.
We include 2007 PIA into distribution and have no any issues with working previous (2003) version of Excel.
MS Office Wrapper for .NET mention here is very nice alternative.
我对 SpreadsheetGear 非常满意。该组件允许您读取和写入 Excel 文件。我用它来报告,客户端机器只有 Excel Viewer(免费)来读取文件并打印它们。
我使用 Excel Viewer 2003,因为 2007 版本有一个打印错误(打印时提示您打开文件对话框)
I am pretty happy with SpreadsheetGear. This component allows you to read and write excel files. I am using it for reporting, client machine has only Excel Viewer (which is free) to read files and print them.
I am using Excel Viewer 2003 because 2007 version has a printing bug (on print it's promt you open file dialog)
您需要下载并安装 适用于您需要的 Office 版本的 Office 互操作程序集。
对于 Office 2003,请从此处下载
对于 Office 2007,请从此处下载
You'll need to download and install the Office Interop Assemblies for the version(s) of Office you need.
For Office 2003, download from here
For Office 2007, download from here