title: Getting AttributeError 'Workbook' object has no attribute 'add_worksheet' - while writing data frame to excel sheet
body: <p>I have the following code, and I am trying to write a data frame into an &quot;existing&quot; worksheet of an Excel file (referred here as test.xlsx). Sheet3 is the targeted sheet where I want to place the data, and I don't want to replace the entire sheet with a new one.</p>
  <pre><code>df = pd.DataFrame({'Data': [10, 20, 30, 20, 15, 30, 45]})
  book = load_workbook('test.xlsx')
  writer = pd.ExcelWriter('test.xlsx')
  writer.book = book
  writer.sheets = dict((ws.title, ws) for ws in book.worksheets) # *I am not sure what is happening in this line*
  df.to_excel(writer,&quot;Sheet3&quot;,startcol=0, startrow=20)
  </code></pre>
  <p>When I am running the code line by line, I am getting this error for the last line:</p>
  <p>AttributeError: 'Workbook' object has no attribute 'add_worksheet'. Now why am I seeing this error when I am not trying to add worksheet ?</p>
  <p>Note: I am aware of this similar issue <a href="https://stackoverflow.com/questions/34744863/python-how-to-use-excelwriter-to-write-into-an-existing-worksheet">Python How to use ExcelWriter to write into an existing worksheet</a> but its not working for me and I can't comment on that post either.</p>