data from Acces to Excel

Carlos Ribeiro cribeiro at mail.inet.com.br
Sun Jul 1 17:55:40 CEST 2001


"baton" <batonn at poczta.fm> wrote, in part:
 > I wonder if there is a possibilyty to export table from Access
 > database to Excel using python language?? If yes, could you tell me
 > how to do it or where I can find info how to do it?

I've done the opposite - importing from Excel to Access. I had to make it 
using Visual Basic for other boss-related reasons, but it is possible to 
make it using Python, using exactly the same techniques. I could not use 
any of the wizards, as some people suggested, because I needed to get data 
that was scattered in several worksheets to build a single database.

Both Access and Excel are able to expose their objects using a very similar 
interface called DAO, that uses a DB metaphor - you have tables and cursors 
to walk in them. In the case of Excel, using the automation interface, it 
is also possible to access all the data using native objects - Worksheets, 
Ranges and Cells are the main objects. Your job is just to open the 
Worksheet object, giving commands to get or set the contents of the desired 
cells using Range objects. All this can be done through Excel's automation 
interface.

The nice thing about doing this in Python is that it is pretty easy to 
prototype. You can actually do a lot of stuff in the interactive mode, 
which mnakes development of this kind of tool very easy. Fire up Python, 
and give it a try. There are some tutorials on the automation feature using 
Python and Excel;  do a search on Google and you'll find them.


Carlos Ribeiro






More information about the Python-list mailing list