0

I'll start off by saying that I'm new to python. I'm trying to create an application that is a simple Q+A and will export the answers to specific cells of an excel. I have an existing spreadsheet that i would like to modify and save as a separate outfile leaving the original untouched. I've seen various ways that i can append the file but will overwrite the original.

As an example, i would like this code;

hq = input('Headquarters: ')

to put the response in cell S1

Am I way off base trying to use Python for this task? Any Help would be greatly appreciated!

-Paul

user225698
  • 13
  • 2
  • possible duplicate of [Driving Excel from Python in Windows](http://stackoverflow.com/questions/441758/driving-excel-from-python-in-windows) – Cory Kramer Jul 13 '14 at 18:31
  • Why not generating a CSV file, (which Excel can open) ? – Julien Palard Jul 13 '14 at 18:48
  • My hope is to use a preformated spreadsheet. I tried to generate a CSV file and it unmerged all the cells and reverted the size formatting. My original seach did not find "Driving Excel from Python". I will read through that, hopefully it is the ticket! – user225698 Jul 13 '14 at 19:30
  • You may also consider driving Libreoffice, it may be easier than Excel (or not, but it worst give a try). – Julien Palard Jul 13 '14 at 20:25

1 Answers1

0

There may not be very straightforward solutions but there are a couple of tools which might help you.

The first one is openpyxl: https://openpyxl.readthedocs.org/en/2.0.2/# If you have xlsx files, you should be able to modify them with this.

You might also be able to do what you want to do by using xlutils module: http://pythonhosted.org/xlutils/index.html However, then you'll need to first read the file, then edit it, and then save it to another file. Formatting may be lost, etc.

This is heavily YMMV due to the not-so-well defined file format, but I'd start with openpyxl.

DrV
  • 22,637
  • 7
  • 60
  • 72