Driving Excel from Python in Windows

2019-01-02 14:40发布

We have various spreadsheets that employ deliciously complicated macros and third party extensions to produce complicated models. I'm working on a project that involves slightly tweaking various inputs and seeing the results. Rather than doing this by hand or writing VBA, I'd like to see if I can write a python script to drive this. In other words, the python script will start up, load the excel sheet, and then interact with the sheet by making minor changes in some cells and seeing how they affect other cells.

So, my question is twofold:

  • What is the best library to use to drive excel from python in such fashion?

  • Where's the best documentation/examples on using said library?

Cheers, /YGA

7条回答
谁念西风独自凉
2楼-- · 2019-01-02 15:31

I worked on a home project last year that involves a client written as a Python Excel plug-in. The project is essentially an online database simplified for end-user access. The Excel plug-in allows users to query data out of the database to display in Excel.

I never got very far with the Excel plug-in and my code for it is a bit ugly. But, what I do have is under a BSD license and available via Bazaar at

http://www.launchpad.net/analyz/trunk

The client won't work since I don't have a public server running right now, but at least you can look at what I did with the code to get some ideas how this could work. The code will also show you how to build an MFC dialog in 100% Python.

查看更多
登录 后发表回答