0

I want a generic python-based method to insert some data into a given Excel workbook (a proforma). The workbook uses formatted sheets - password protected, with limits on which cells can be written to and what can be written into a cell (sometimes via menus of acceptable input). The data I wish to insert would be acceptable content to the protected cells, if human typed.

I don't want to spoil the fancy formatting, just to emulate the act of typing and then saving. I need the option of manually adding more information later via Excel.

So far I have looked at xlrd/xlutils.copy/xlwt, but don't see how to preserve the fancy formatting - the protection gets stripped off, the menus disappear, and so on.

Any suggestions?

1 Answers1

1

Your best bet is pywin32, by Mark Hammond. With that, you control a running instance of Excel via COM (somewhat like programming in VBScript or VBA, except using Python syntax). See this earlier Stack Overflow question for more details, as well as some other potential options.

Community
  • 1
  • 1
John Y
  • 14,123
  • 2
  • 48
  • 72