title: Openpyxl corrupted my excel file and now it is lost?
body: <p>I have been using openpyxl to write some data to an already existing Excel file and I was finding it quite user friendly and easy. 
  However, things started to go wrong yesterday.</p>
  
  <p>The excel file that my python code loads has some titles in A2, B2, C2, e.t.c. and the code prints some data below each column.  </p>
  
  <p>During the afternoon I ran the code (I have been running it a lot and doing lots of trial and error) and it worked exactly as hoped except a few columns in various sheets of the Excel file had mysteriously disappeared.  This was because some columns (mostly where there was data) had been minimized to 0 pixels wide for some reason, and once I had expanded the column wider again, everything was as it should be.  One of the sheets that had had columns being minimized was not being touched by the code.  Not sure if this is relevant but found it strange so thought I'd add it anyway.</p>
  
  <p>Then during the evening, I ran the code again trialing a couple of new functions I had added.  It looked to be working fine, but when it got to the .save() command at the end it threw out all these errors:</p>
  
  <hr>
  
  <pre><code> Traceback (most recent call last):
  File "whoscored_scraper.py", line 239, in &lt;module&gt;
  wb2.save("WhoscoredDatabase.xlsx")
  File "C:\Users\SamH\Documents\Betting\Python\openpyxl\workbook\workbook.py", l
  ine 296, in save
  save_workbook(self, filename)
  File "C:\Users\SamH\Documents\Betting\Python\openpyxl\writer\excel.py", line 1
  91, in save_workbook
  writer.save(filename, as_template=as_template)
  File "C:\Users\SamH\Documents\Betting\Python\openpyxl\writer\excel.py", line 1
  74, in save
  self.write_data(archive, as_template=as_template)
  File "C:\Users\SamH\Documents\Betting\Python\openpyxl\writer\excel.py", line 8
  5, in write_data
  self._write_worksheets(archive)
  File "C:\Users\SamH\Documents\Betting\Python\openpyxl\writer\excel.py", line 1
  11, in _write_worksheets
  write_worksheet(sheet, self.workbook.shared_strings,
  File "C:\Users\SamH\Documents\Betting\Python\openpyxl\writer\worksheet.py", li
  ne 299, in write_worksheet
  xf.write(comments)
  File "C:\Users\SamH\Documents\Betting\Python\lib\contextlib.py", line 24, in _
  _exit__
  self.gen.next()
  File "C:\Users\SamH\Documents\Betting\Python\openpyxl\xml\xmlfile.py", line 51
  , in element
  self._write_element(el)
  File "C:\Users\SamH\Documents\Betting\Python\openpyxl\xml\xmlfile.py", line 78
  , in _write_element
  xml = tostring(element)
  File "C:\Users\SamH\Documents\Betting\Python\lib\xml\etree\ElementTree.py", li
  ne 1126, in tostring
  ElementTree(element).write(file, encoding, method=method)
  File "C:\Users\SamH\Documents\Betting\Python\lib\xml\etree\ElementTree.py", li
  ne 820, in write
  serialize(write, self._root, encoding, qnames, namespaces)
  File "C:\Users\SamH\Documents\Betting\Python\lib\xml\etree\ElementTree.py", li
  ne 939, in _serialize_xml
  _serialize_xml(write, e, encoding, qnames, None)
  File "C:\Users\SamH\Documents\Betting\Python\lib\xml\etree\ElementTree.py", li
  ne 939, in _serialize_xml
  _serialize_xml(write, e, encoding, qnames, None)
  File "C:\Users\SamH\Documents\Betting\Python\lib\xml\etree\ElementTree.py", li
  ne 932, in _serialize_xml
  v = _escape_attrib(v, encoding)
  File "C:\Users\SamH\Documents\Betting\Python\lib\xml\etree\ElementTree.py", li
  ne 1092, in _escape_attrib
  _raise_serialization_error(text)
  File "C:\Users\SamH\Documents\Betting\Python\lib\xml\etree\ElementTree.py", li
  ne 1052, in _raise_serialization_error
  "cannot serialize %r (type %s)" % (text, type(text).__name__)
  TypeError: cannot serialize 7L (type long)
  </code></pre>
  
  <hr>
  
  <p>My code is quite long, so below are some of the lines that involve openpyxl:</p>
  
  <hr>
  
  <pre><code>from openpyxl import workbook
  from openpyxl import load_workbook
  wb2 = load_workbook('filename.xlsx')
  ws = wb2["Shots_and_Goals"]
  ws4 = wb2["Assorted"]
  ws2 = wb2["On_Target"]
  
  def HomeTeam(string):
      HomeTeam_cell = “c” + str(3)
      ws[str(HomeTeam_cell)] = Home_Team   #Home_Team is some variable
  
  def Home_Shot_Minutes(string):
     for num in range (0, 10):
         cell = column_titles[num+10] + str(3)] #column_titles is just a list
         ws[str(cell)] = int(shot_count_for_that_minute)    #shot_count_for_that_minute is variable defined above
  
  HomeTeam(data)
  Home_Shot_Minutes(data)
  Wb2.save(“filename.xlsx”)
  </code></pre>
  
  <hr>
  
  <p>There’s a lot more lines of code that are basically the same as those listed above.  Everything had been working correctly up until this point.</p>
  
  <p>When I try and open the new saved file, it says Excel has found unreadable content 
  When I say I want to recover the unreadable content, my new excel file is totally blank apart from the sheet names.</p>
  
  <p>I know it was a stupid decision to not save the file as a different filename as then it would mean I don’t have to remake my entire Excel file!</p>
  
  <p>Does anyone understand what went wrong here?</p>