简体   繁体   English

使用Mac OS X / Linux开发Excel XLL

[英]Developing an Excel XLL using Mac OS X / Linux

I've been developing C++ models using Visual Studio for the past 5 years, and wrapped them into Xll to be used with Excel (using xlw). 在过去的5年里,我一直在使用Visual Studio开发C ++模型,并将它们包装到Xll中以与Excel一起使用(使用xlw)。 The Excel add-in is the final product I want to deliver. Excel加载项是我想要提供的最终产品。

However, I believe C++ coding is way better using Linux or Mac OS X. But I also believe using my models with Excel through the Xll is also very practical, but sadly only works on Windows. 但是,我相信使用Linux或Mac OS X可以更好地使用C ++编码。但我也相信通过Xll使用我的模型和Excel也非常实用,但遗憾的是只适用于Windows。

So I would like to know if there is a way to do the implementation on Mac OS X (or Linux), generate the Excel add-in and use it on Windows. 所以我想知道是否有办法在Mac OS X(或Linux)上实现,生成Excel加载项并在Windows上使用它。

The only method to do so that I'm currently thinking of is doing the coding on Mac OS X, compile the project without including the part concerning the Xll, then load the project into Visual Studio and compile it entirely to generate the Excel add-in. 我目前正在考虑的唯一方法是在Mac OS X上进行编码,编译项目时不包含有关Xll的部分,然后将项目加载到Visual Studio中并完全编译以生成Excel添加 - 在。 But to be honest, this sounds a bit laborious, and I'm hoping for an easier way. 但说实话,这听起来有点费劲,我希望有一个更简单的方法。

I've developed a working example of a C++ Excel addin using Mac OSX, Eclipse CDT and XCode and a spreadsheet that uses the addin. 我使用Mac OSX,Eclipse CDT和XCode以及使用插件的电子表格开发了一个C ++ Excel插件的工作示例。 An explanation is here http://www.smr.co.uk/excel-addin-on-mac-os-x-using-cdt/ including versions used etc and the code is here https://github.com/PollardsEtFilles/MacCPPExcelAddinExample . 这里有一个解释http://www.smr.co.uk/excel-addin-on-mac-os-x-using-cdt/包括使用的版本等,代码在这里https://github.com/PollardsEtFilles / MacCPPExcelAddinExample

There are two gotchas 有两个陷阱

  • Excel 2011 is 32 bit Excel 2011是32位
  • Make sure the addin in the same directory as the excel spreadsheet 确保插件与excel电子表格位于同一目录中

clang (included with Xcode) is a good replacement for g++ clang(包含在Xcode中)是g ++的一个很好的替代品

All you need to do is install Eclipse CDT and import the code you'll be away. 您需要做的就是安装Eclipse CDT并导入您将要离开的代码。

It is possible. 有可能的。 You just need to use mingw (http://mingw-w64.sourceforge.net/) to compile from Linux. 你只需要使用mingw(http://mingw-w64.sourceforge.net/)从Linux编译。 I should note that you can then use g++ 4.7, which is a very decent C++ compiler with support for C++ 11x. 我应该注意,你可以使用g ++ 4.7,这是一个非常不错的C ++编译器,支持C ++ 11x。 The cross-compilers work both in Mac and Linux, and because it is gcc, you can use them with your favorite tool ecosystem. 交叉编译器可以在Mac和Linux上运行,因为它是gcc,您可以将它们与您喜欢的工具生态系统一起使用。

There are few unexpected quirks, but just in case: 几乎没有意外的怪癖,但以防万一:

  • Remember to use -Wl,--add-stdcall-alias to get functions exported with no underscore in the final dll. 请记住使用-Wl, - add-stdcall-alias来获取在最终dll中没有下划线导出的函数。
  • Instead of declspec(__declexport) use __attribute ((dllexport)). 而不是declspec(__ declexport)使用__attribute ((dllexport))。 But you can also use the more antique .def trickery, if you wish. 但如果你愿意,你也可以使用更古老的.def技巧。 In any case, use the Windows sdk tools "Depends.exe" or similar to ensure that your dll exports correctly the names. 在任何情况下,使用Windows sdk工具“Depends.exe”或类似工具,以确保您的DLL正确导出名称。
  • If your are using a virtual machine for testing, or any fresh Excel installation, remember to install all the bells and whistles that come with Office and Excel. 如果您正在使用虚拟机进行测试或任何新的Excel安装,请记住安装Office和Excel附带的所有铃声和口哨声。 Otherwise, in Excel 2007 and Excel 2010, the addins won't work, and you will mistakenly blame your build setup. 否则,在Excel 2007和Excel 2010中,插件将无法正常工作,您将错误地归咎于您的构建设置。

Also, if you are up for using http://kalx.net/xll/ , which indeed can make your life simpler, you will have to update that library for strict C++ conformance. 此外,如果您正在使用http://kalx.net/xll/ ,这确实可以使您的生活更简单,您将不得不更新该库以实现严格的C ++一致性。

Best regards. 最好的祝福。

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

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