从excel使用python函数的最佳方法是什么?

时间:2022-02-22 23:14:45

Somebody really needs to fix this "subjective questions evaluator"

有人真的需要解决这个“主观问题评估员”

I usually compile my functions in a DLL and call them from excel. That works fine (well, let's just say it works)

我通常在DLL中编译我的函数并从excel中调用它们。这工作正常(好吧,我们只是说它有效)

Unfortunatelly, python cannot be compiled. I know of py2exe but I don't know that it can make a DLL.

不幸的是,python无法编译。我知道py2exe但我不知道它可以制作DLL。

So, ..., is there any other way ? I appreciate all ideas and suggestions on the matter.

那么,......,还有其他方法吗?我很欣赏有关此事的所有想法和建议。

6 个解决方案

#1


0  

There is an Excel Addin that allows you to do this called Discovery Script at xefion.com.

有一个Excel Addin允许您在xefion.com上执行此命名的Discovery Script。

It's free but not open source. It's also based on the IronPython implementation.

它是免费的,但不是开源的。它也基于IronPython实现。

#2


7  

One way is to write a COM server in Python, and call that from Excel. There are tutorials describing Win32 COM servers, and screencasts on calling such servers from Excel.

一种方法是在Python中编写COM服务器,并从Excel调用它。有一些教程描述了Win32 COM服务器,以及从Excel调用此类服务​​器的截屏视频。

#3


4  

This is probably not a possible solution for you, but there is the Resolver One spreadsheet application (which is like Excel combined with Python). It is not connected with Excel in any way, but claims to be compatible to some extent.

这可能不是一个可能的解决方案,但有Resolver One电子表格应用程序(就像Excel结合Python)。它没有以任何方式与Excel连接,但声称在某种程度上兼容。

#4


4  

Im surprised nobody mentioned pyxll. From the website:

我很惊讶没有人提到pyxll。来自网站:

PyXLL is an Excel addin that enables functions written in Python to be called in Excel. Python functions can either be exposed as Excel user defined functions that can be called from worksheets, as custom menu items, or as macros.

PyXLL是一个Excel插件,可以在Excel中调用用Python编写的函数。 Python函数可以作为Excel用户定义的函数公开,可以从工作表,自定义菜单项或宏中调用。

#5


0  

I don't know any py2dll similar to py2exe.

我不知道任何类似于py2exe的py2dll。

However, you could create a dll in C and use the Very High Level Layer to call your script. I don't know it is an acceptable solution for you. Just an idea.

但是,您可以在C中创建一个dll并使用Very High Level Layer来调用您的脚本。我不知道这对你来说是一个可以接受的解决方案。只是一个想法。

#6


0  

I had to do this some years back. My solution was to run small Python server that exported the functions using SOAP, then call the functions using Visual Basic's SOAP library. The advantage is that you don't have to ship a Python environment with your spreadsheets. The disadvantage is that the clients will need a network connection.

几年前我不得不这样做。我的解决方案是运行使用SOAP导出函数的小型Python服务器,然后使用Visual Basic的SOAP库调用这些函数。优点是您不必使用电子表格发布Python环境。缺点是客户端需要网络连接。

#1


0  

There is an Excel Addin that allows you to do this called Discovery Script at xefion.com.

有一个Excel Addin允许您在xefion.com上执行此命名的Discovery Script。

It's free but not open source. It's also based on the IronPython implementation.

它是免费的,但不是开源的。它也基于IronPython实现。

#2


7  

One way is to write a COM server in Python, and call that from Excel. There are tutorials describing Win32 COM servers, and screencasts on calling such servers from Excel.

一种方法是在Python中编写COM服务器,并从Excel调用它。有一些教程描述了Win32 COM服务器,以及从Excel调用此类服务​​器的截屏视频。

#3


4  

This is probably not a possible solution for you, but there is the Resolver One spreadsheet application (which is like Excel combined with Python). It is not connected with Excel in any way, but claims to be compatible to some extent.

这可能不是一个可能的解决方案,但有Resolver One电子表格应用程序(就像Excel结合Python)。它没有以任何方式与Excel连接,但声称在某种程度上兼容。

#4


4  

Im surprised nobody mentioned pyxll. From the website:

我很惊讶没有人提到pyxll。来自网站:

PyXLL is an Excel addin that enables functions written in Python to be called in Excel. Python functions can either be exposed as Excel user defined functions that can be called from worksheets, as custom menu items, or as macros.

PyXLL是一个Excel插件,可以在Excel中调用用Python编写的函数。 Python函数可以作为Excel用户定义的函数公开,可以从工作表,自定义菜单项或宏中调用。

#5


0  

I don't know any py2dll similar to py2exe.

我不知道任何类似于py2exe的py2dll。

However, you could create a dll in C and use the Very High Level Layer to call your script. I don't know it is an acceptable solution for you. Just an idea.

但是,您可以在C中创建一个dll并使用Very High Level Layer来调用您的脚本。我不知道这对你来说是一个可以接受的解决方案。只是一个想法。

#6


0  

I had to do this some years back. My solution was to run small Python server that exported the functions using SOAP, then call the functions using Visual Basic's SOAP library. The advantage is that you don't have to ship a Python environment with your spreadsheets. The disadvantage is that the clients will need a network connection.

几年前我不得不这样做。我的解决方案是运行使用SOAP导出函数的小型Python服务器,然后使用Visual Basic的SOAP库调用这些函数。优点是您不必使用电子表格发布Python环境。缺点是客户端需要网络连接。