excel 互操作 api 支持有多广泛?

How wide is the excel interop api support?

我正在使用 Excel Interop API 来处理 excel 工作表,因为这似乎是使用公式的最佳 api。
我的问题是这个 API 的支持范围有多广?
例如,如果某人的 Microsoft Office 版本比我旧或新,他们可以使用该软件吗?
我在 Office 365 中使用它。

My question is that how wide is the support for this API? For example if someone who has an older or newer version of Microsoft Office than me, will they be able to use the software?

答案是肯定的,你的软件可以运行不同的Office版本。您只需要通过检查主机版本并决定调用特定方法或最近版本中引入的 属性 来确保已安装版本中存在方法和属性。

因此,我建议使用与您的软件支持的最低 Office 版本相对应的最低版本的互操作库。通过使用最低的互操作版本,您可以确保处理所有 Office 版本中可用的属性和方法,并且在 运行 时不会抛出异常。

如果您需要使用最新 Office 版本中可用的方法和属性,您可以考虑使用具有 System.Type.InvokeMember 方法的 .Net 应用程序中可用的后期绑定技术。在 Supporting several Office versions in an add-in. Interop assemblies and late binding. 文章中阅读更多相关信息。