使用 .NET Core 在 Mac OSX 上的 Office (Excel) COM 互操作? [英] Office (Excel) COM interop on Mac OSX using .NET Core?

查看:35
本文介绍了使用 .NET Core 在 Mac OSX 上的 Office (Excel) COM 互操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为一个团队工作,该团队目前专门在 C#/.NET 中创建 Windows 桌面应用程序,这些应用程序通过 Office COM Interop 与 Microsoft Excel 的本地用户实例交互.我目前负责指定新产品,但有人告诉我,除非该应用程序可以在 Mac 和 Windows 上运行,否则该项目不会继续进行——也就是说,我们必须能够生成该应用程序的 Mac 版本可以在 OSX 上本地安装并与用户的 Microsoft Excel for Mac 实例的对象模型进行交互.

I work for a team that currently specializes in creating windows desktop applications in C#/.NET that interwork with local user instances of Microsoft Excel via Office COM Interop. I am currently charged with specifying a new product but I’ve been told that the project will not go ahead unless the app can run on Mac as well as Windows – that is, we have to be able to produce a Mac version of the app that can install natively on OSX and interact with the object model of a user’s instance of Microsoft Excel for Mac.

使用 Parallels、Mono 或 Wine 运行应用程序(参见 OSX 中通过 Wine 的 COM 互操作(从未有人回答)不是解决方案,因为该应用程序的规范要求不得以任何方式修改用户机器.我们只需要假设用户有一个许可的 Excel 本地副本在运行,然后使用它……这就是我们一直在 Windows 上所做的事情,在那里它工作得很好.

Running the app with Parallels, Mono or Wine (see COM Interop Through Wine in OSX, which was never answered) is not a solution because the spec for the app requires that the user machine is not modified in any way. We just have to assume the user has a licenced local copy of Excel running, and work with that… which is what we have always done on Windows, where it works great.

我认为 .NET Core 是答案,但我找不到任何地方明确说明我们可以(或将能够)在 Mac OSX 上使用本地运行 .NET Core 时从 C# 访问 Excel 对象库已安装 Excel for Mac 的副本.任何人都可以指出我已经讨论过的地方吗?但如果没有,请告诉我如何从 Microsoft 那里了解这是否在他们的 .NET Core 路线图中?

I think .NET Core is the answer but I can’t find anywhere where it says definitely that we can (or will be able to) access the Excel Object Library from C# when running .NET Core on Mac OSX with a local copy of Excel for Mac installed. Can anybody point me please to where this has been discussed already; but if not, then tell me how I can go about finding out from Microsoft if this is in their roadmap for .NET Core?

推荐答案

我从 MSDN 上一个措辞类似的问题中收到了一些有用的反馈.我也在.NET Core Github上发了一个issue,但是我想这个问题的答案已经很清楚了,如下:

I have received some helpful feedback from a similarly worded question on MSDN. I have also posted an issue on the .NET Core Github, but I think it is already clear what the answer is to this, which is as follows:

  • 也许可以说服 .NET Core 团队在 .NET Core 类库中添加对 Office.Interop.Excel 命名空间的访问,但仅适用于 Windows
  • 这不能在 OSX 上为 .NET Core 完成,因为环境是不适合交换 COM 对象.
  • 这仅剩下两个用于在 Excel 中操作对象的选项Mac,两者都已经存在:嵌入式 VBA 或 Javascript (Office插件).
  • Office Addins 是一款出色的全新解决方案,适用于 Web 驱动的、面向数据的Excel 中的对象 - 它的多平台性质非常棒 - 所以享受来自微软的开发.然而,它并不打算成为任何与 COM 管理复杂电子表格的性能相匹配,因为这不是它的重点.
  • 这意味着没有在 Excel 中管理对象的解决方案对于使用 C# 的 Mac,就像在 Windows 上一样,还有似乎没有任何前景.

底线:非常受欢迎的 .NET Core 计划看起来像是一个修复,但遗憾的是不是,因为 OSX 的架构限制.

The bottom line: The very welcome .NET Core initiative looked like it was a fix, but sadly isn't, because of architecture limitations on OSX.

我已经提交了这个作为答案,因为我想我已经到了关于它的查询行的末尾,但如果有人认为以上任何一条是不正确的,请大喊!

I have submitted this as an answer because I think I've come to the end of the line of enquiry on it, but if anyone thinks any of the above is incorrect, please shout!

谢谢.

这篇关于使用 .NET Core 在 Mac OSX 上的 Office (Excel) COM 互操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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