title: Python how to export dataframes to two tabs in xlsx
body: <p>I want to export dataframe C to an existing excel, saving it in a new tab.
  I tried:</p>
  
  <pre><code>writer=pd.ExcelWriter(r'H:\test.xlsx', engine='xlsxwriter')
  C.to_excel(writer,sheet_name='c') 
  writer.save()
  </code></pre>
  
  <p>(Notice: Excel test is an <strong>existing</strong> and previously saved Excel, with different tables A, B in tabs a, b, which I want to keep)</p>
  
  <p>This code however deletes the existing excel and creates a new one with only the tab "c". I want to keep the existing tabs "a" and "b".</p>
  
  <p>What is the right way?</p>
  
  <p>ps: I tried  suggestion on link "How to save a new sheet in an existing excel file, using Pandas? "  as follows:</p>
  
  <pre><code>writer=pd.ExcelWriter(r'H:\C.xlsx', engine='xlsxwriter')
  y_pred_all2.to_excel(writer,sheet_name='cc')
  writer.save()
  writer.close()
  from openpyxl import load_workbook
  path=r'H:\C.xlsx'
  book=load_workbook(path)
  writer=pd.ExcelWriter(path, engine='xlsxwriter')
  writer.book=book
  C.to_excel(writer,sheet_name='returns') 
  </code></pre>
  
  <p>This gives me error: AttributeError: 'Workbook' object has no attribute 'add_worksheet'</p>