Dealing with Excel

McBooCzech petr at tpc.cz
Tue Oct 18 18:52:28 EDT 2005


Robert
Sorry I was not more clear in my posting. I am solving similar problem
as you are.

1) I am getting my data from the Firebird SQL database - directly,
using SQL commands (kinterbasdb module), not using ODBC, or ADODB or
what ever - some people here can suggest you how to connect directly to
the Oracle.

2) In the Python code, I am processing data I have got from the
Firebird (I have data stored in the two dimensional list usually)

3) I am setting up the Excel cell range according to the final size of
data using Visual Basic for Applications commands for example:

rng=xlApp.Range(xlApp.Cells(1,1),xlApp.Cells(len(rw),len(rw[0])))

4) I am putting data from the Python to the Excel
rng.Value=rw

5) I am formatting the data in the Excel worksheet using the VBA code
from the Python code and finally I can save it, (it is possible get
Excel under the full control from the Python).

That's it!

I am just a newbie in the Python, so I somebody here can show you
different (better) way to go, but above mentioned works for me great.

If you are looking for the way how to create (generate) the Excel file
directly from the Python, I didn't find it. The only simple way I have
found in this discussion group is to save your data separated by
semicolons in the file with the .csv extension. Excel will recognize it
as an Excel file and open it without problems.

Petr Jakes




More information about the Python-list mailing list