0

I am trying to write a dataframe to an existing excel document without having to load the workbook.

The reason is because my excile file contains many pivot table which can not be read-in to python. Therefore i want to know whether it is possible to write directly to the excel file (and specific sheet) without having to load the workbook.

I have previously tried writing to an excel file, but this simply deletes the other existing sheets and just leaves the data i have written in. so to clarify i will need to make sure the other sheets are not deleted.

thanks in advance.

as background, this code will NOT work for me

path = xxxxxxx
#loading workbook
book = load_workbook(path)
# book = load_workbook(path, read_only=False, keep_vba=True)
#object which writes to the workbook
writer = pd.ExcelWriter(path, engine='openpyxl') 
#where object and loadworkbook are introduced
writer.book = book

#writing in all sheet names from the workbook
writer.sheets = dict((ws.title, ws) for ws in book.worksheets)
Kiri18
  • 11
  • 3
  • check this out [appending excel sheet to dataframe](https://stackoverflow.com/questions/38074678/append-existing-excel-sheet-with-new-dataframe-using-python-pandas) – satyam soni Jul 23 '19 at 11:24
  • HI, i had a look at this but this still requires to load the workbook which is what i need to avoid. – Kiri18 Jul 23 '19 at 16:30

0 Answers0