title: writing and appending to excel from pandas dataframe not working
body: <p>I am trying to write pandas dataframe (allagents) to excel sheet...If the file is not there it should create a new file and if file is already there, it should append the data at the end. Below is my code..</p>
  <pre><code>try:
      output_file = &quot;all_agents_file.xlsx&quot;
      # try to open an existing workbook
      book = load_workbook(output_file)
      writer = pd.ExcelWriter(output_file)
      writer.book = book
      # copy existing sheets
      writer.sheets = dict((ws.title, ws) for ws in writer.book.worksheets)
      # read existing file
      previous_data = pd.read_excel(output_file)
  
      # write out the new sheet
      if not all_agents.empty:
          all_agents.index = np.arange(len(previous_data) + 1,
                                       len(previous_data) + len(all_agents) + 1)
          all_agents.to_excel(writer, index=True, header=False,
                              startrow=len(previous_data) + 1)
      writer.close()
  
  except Exception as e:
      all_agents.index = np.arange(1, len(all_agents) + 1)
      all_agents.to_excel(output_file)
  
      print(&quot;File Created and Data Written in it...:&quot;, e)
  </code></pre>
  <p>The issue is it shows Exception like File is not a recognised excel file and if I specify engine=&quot;openpyxl&quot; while reading, it gives Exception as File is not a zip file, if I give engine as &quot;xlsxwriter&quot;, it gives exception as unknown engine xlsxwriter pandas==1.2.5, openpyxl==3.0.7</p>
  <p>My machine is Ubuntu and the same code works on Jupyter notebook on my machine....But does not work when I run through terminal.</p>
  <p>Any help would be appreciated</p>