I have an excel document (with formatting and everything) the first several lines are title and header stuff.
On line 11, I start with actual data, with column headers and everything.
I'm computing data to put into this table.
I can read the data with header=[11], and it will read in with the correct column names, and index and everything. I can fill in my data, adding columns as needed, etc.
The problem comes when I try to save the file. If I just save with to_excel, it saves, but without any of the title stuff, or formatting of the original.
How do I plug my dataframe into a spot in an existing excel document?
ETA:
One thing that I forgot to mention that may be important is that the original excel file also has conditional formatting all through the data portion. I want to maintain that.
ETA2: adding details for Josh's comment.
In [153]: xl.to_excel(writer, "Program Area Summary.xls", startrow=11)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-153-6541427c4a61> in <module>()
----> 1 xl.to_excel(writer, "Program Area Summary.xls", startrow=11)
/Users/brianp/work/cyan/venv/lib/python2.7/site-packages/pandas/core/frame.pyc in to_excel(self, excel_writer, sheet_name, na_rep, float_format, columns, header, index, index_label, startrow, startcol, engine, merge_cells, encoding, inf_rep, verbose)
1422 formatted_cells = formatter.get_formatted_cells()
1423 excel_writer.write_cells(formatted_cells, sheet_name,
-> 1424 startrow=startrow, startcol=startcol)
1425 if need_save:
1426 excel_writer.save()
/Users/brianp/work/cyan/venv/lib/python2.7/site-packages/pandas/io/excel.pyc in write_cells(self, cells, sheet_name, startrow, startcol)
1243 wks = self.book.create_sheet()
1244 wks.title = sheet_name
-> 1245 self.sheets[sheet_name] = wks
1246
1247 for cell in cells:
TypeError: list indices must be integers, not str
I did this in ipython, so there isn't really much other code. xl is a dataframe.