title: openpyxl - overwrite datasheet and preserve pivot table
body: <p>I've seen a few answers around to this question but none of them are working.
  eg: <a href="https://stackoverflow.com/questions/20262448/how-to-write-to-an-existing-excel-file-without-breaking-formulas-with-openpyxl">How to write to an existing excel file without breaking formulas with openpyxl?</a></p>
  
  <p>Docs give nothing away it seems:
  <a href="http://openpyxl.readthedocs.io/en/latest/api/openpyxl.reader.excel.html" rel="nofollow noreferrer">http://openpyxl.readthedocs.io/en/latest/api/openpyxl.reader.excel.html</a>
  I tried replacing <code>xls.load_workbook</code> with <code>xls.reader.excel.load_workbook</code> but it doesn't change anything.</p>
  
  <p>My current code overwrites the data in the data sheet, but kills the pivot table functionality in the other sheet (the sheet is still there but only with values). Any idea how to keep the pivot table?</p>
  
  <pre><code>import pandas as pd
  import openpyxl as xls
  from shutil import copyfile
  
  template_file = 'openpy_test.xlsx' 
  output_file = 'openpy_output.xlsx' 
  
  copyfile(template_file, output_file)
  
  book = xls.load_workbook(output_file,guess_types=False,data_only=False)
  writer = pd.ExcelWriter(output_file,engine='openpyxl')
  
  writer.book = book
  writer.sheets = dict((ws.title, ws) for ws in book.worksheets)
  
  df.to_excel(writer,sheet_name='data',index=False,encoding='utf8')
  writer.save()
  </code></pre>
  
  <p>I have also tried <code>book.save('dummycopy.xlsx')</code>, which also saves with a non-funcitoning pivot table. So I am sure the problem is related to the load_workbook function.</p>
  
  <p>Package versions:</p>
  
  <p>openpyxl                  2.4.10                   py36_0</p>
  
  <p>pandas                    0.20.3           py36hce827b7_2</p>