适用于Mac的Excel xlwings 2016 [英] xlwings for Excel for Mac 2016

查看:481
本文介绍了适用于Mac的Excel xlwings 2016的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Mac OS X Sierra与Mac一起用于Ecel 2016和python 3.6.我正在尝试从excel启动python脚本,因为:

I am using mac OS X Sierra with Mac for Ecel 2016 and python 3.6. I am trying to launch a python script from excel because:

  • 我已经具有许多功能的excel,并且我想使用Python向该产品添加一些功能.
  • 我的产品的用户不太喜欢从python控制台启动python脚本,因此我想拥有某种excel用户界面.

我提供此背景信息是因为我愿意就如何做不同的事情提出建议.从到目前为止的研究来看,似乎可以使用xlwings库完成此操作.我已经尝试按照以下说明使用它:

I am providing this background because I am open to suggestions on how to do differently. From my researches so far, it seems that this can be done using the xlwings library. I have tried using it following the instructions on:

http://docs.xlwings.org/en/stable/vba .html#vba

在这个阶段,我莫名其妙地被困住了:

I am somehow stuck at this stage:

使用Alt-F11打开VBA编辑器 然后转到文件>导入文件...,然后导入xlwings.bas文件.可以在xlwings安装目录中找到它.

Open the VBA editor with Alt-F11 Then go to File > Import File... and import the xlwings.bas file. It can be found in the directory of your xlwings installation.

由于alt + F11不能打开宏编辑器,因此我了解以下说明:

As alt + F11 doesn't open the macro editor, I have understood the instructions as follows:

  • 单击excel开发人员"标签中的宏"按钮
  • 创建新宏/编辑现有宏
  • 转到左下角的添加引用"
  • 打开提到的文件

问题是我无法打开xlwings.bas文件;我只能打开一些文件.我设法打开一个名为xlwings.xlsm的文件;在Excel上创建一个名为"xlwings"的新标签,其中有一个按钮:导入Python UDF".当我按下此按钮时,将引发错误:

The issue is that I can't open the xlwings.bas file ; I can only open some of the files. I managed to open a file called xlwings.xlsm ; that creates a new tab called 'xlwings' on Excel, in which there is one button: 'import Python UDFs'. When I press this button it throws the error :

运行时错误'53': 找不到文件:xlwings64.dll

Run-time error '53': File not found: xlwings64.dll

在我以前使用xlwings的尝试之一中,我在此阶段遇到了另一个错误.我记不清了,但是从我的研究中,该解决方案暗示要在excel 2016的信任中心上执行某些操作,而这在Excel for Mac 2016中是无法做到的.

In one of my previous attempts using xlwings, I had a different error at this stage. I cant remember it, but from my researches the solution implied doing something on the trust center of excel 2016 which I couldn't do with Excel for Mac 2016.

或者,当我尝试使用RunPython运行宏时,它会引发以下错误:

Alternatively, when I try to run a macro using RunPython, it throws the following error :

编译错误: 子或功能未定义

Compile error: Sub or Function not defined

指向RunPython ...

Pointing at RunPython...

如果有人知道我做错了什么和/或我如何设法使用xlwings,那将是很好的.

If someone knows what I did wrong and/or how I can manage to use xlwings, that would be great.

感谢您的帮助,

推荐答案

对于您的信息,我发现的最佳解决方案(感谢Xukrao)是从

For your information, the best solution that I found (thanks to Xukrao) was to download an example from xlwingsexamples, go to the macro editor, copy the "xlwings" module that is in the example worksheet and paste it in the macros of my worksheet.

这篇关于适用于Mac的Excel xlwings 2016的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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