views:

259

answers:

4
+1  Q: 

Excel and Django

I have an excel spreadsheet with calculations I would like to use in a Django web application. I do not need to present the spreadsheet as it appears in excel. I only want to use the formulae embedded in it. What is the best way to do this?

A: 

I think the only thing you can do is use some python/excel mechanism (the only one I could find was this: http://www.python-excel.org/; the tutorial makes me think it might be doable) to read and write from an excel spreadsheet.

You would write to certain cells that would be used by the spreadsheet formulas and then read the results from the formulas from other cells.

Django per-se has nothing to help you with this.

I'll retag your question to include python so that, maybe, someone with Python-excel experience can comment...

celopes
That leaves the issue of how to get the excel runtime working in a hosted situation(?)
liminal
Have no clue - hence the retagging and hoping for a python person with experience doing this thing...
celopes
None of the software at python-excel.org will evaluate Excel formulas. To do that you need an Excel process. In a NON-hosted environment, this can be done but it's painful.
John Machin
+3  A: 

You can control Excel with Python via COM. See this thread: http://stackoverflow.com/questions/441758/driving-excel-from-python-in-windows

It might be a challenge to get this to work reliably as part of a Django app.

Daniel Hepper
This is the direction we're going for now and reliability is proving elusive. Hopefully we sort it out soon.
liminal
A: 

You need to use Excel to calculate the results? I mean, maybe you could run the Excel sheet from OpenOffice and use a pyUNO macro, which is somehow "native" python.

A different approach will be to create a macro to generate some more friendly code to python, if you want Excel to perform the calculation is easy you end up with a very slow process.

Khelben
+1  A: 

In addition to the COM solution, xlrd is cross-platform. That might be more suitable, since I believe Linux is still the most common deployment environment for django. It's also a lighter-weight solution than pyUno.

Ryan Ginstrom