tags:

views:

225

answers:

5

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)

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

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

+5  A: 

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.

Martin v. Löwis
A: 

I don't know any py2dll similar to py2exe.

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.

luc
+5  A: 

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.

nikow
Resolver One looks like an excellent product, but it is totally separate from Excel. However, if the OP doesn't need to share his or her spreadsheet as an actual Excel document, it might be perfect. Any Python code should just drop right in, and be called from the worksheet just like VBA would be in Excel.
jtolle
Yes, it is separate, I clarified my answer to reflect that.
nikow
Unfortunatelly, I do need an excel compatibility. I waas hoping to avoid rewriting python code which I have now into fortran, and then compiling it to a dll, but according to these experiences, that will be the case.
ldigas
I think the compatibility is limited to the ability to import an Excel spreadsheet into Resolver One, but not the other way around.
jtolle
(Full disclosure: I'm a Resolver Systems employee)You can import Excel sheets into Resolver One, and then export them in Excel format, either with formulae or converting all of the formulae into their results. It also supports many Excel functions, and (as you mention fortran) we also support NumPy in the grid -- eg. a cell can contain a NumPy array.Hope that helps.
Giles Thomas
Giles, Thanks for the correction. I mainly meant that you can't do something nifty in Python/Resolver and export the full functionality back to Excel. Is that correct? I'm looking for a way to use Resolver One on a commercial project but so many people are determined that "spreadsheet" = "Excel"...
jtolle
A: 

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.

+1  A: 

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

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

Robert Christie