Saving this workbook fails

Issue #1197 resolved
emery@cs.umass.edu created an issue

Opening this sheet as not read-only and saving it fails reliably. Worked with a previous version.

import openpyxl

fname = "sheets/subjects_xlsx/01sumdat.xlsx"
outname = "testme.xlsx"

workbook = openpyxl.load_workbook(filename=fname, read_only=False)
workbook.save(outname)
$ python repro.py 
Traceback (most recent call last):
  File "repro.py", line 7, in <module>
    workbook.save(outname)
  File "/Users/emery/anaconda3/lib/python3.7/site-packages/openpyxl/workbook/workbook.py", line 396, in save
    save_workbook(self, filename)
  File "/Users/emery/anaconda3/lib/python3.7/site-packages/openpyxl/writer/excel.py", line 294, in save_workbook
    writer.save()
  File "/Users/emery/anaconda3/lib/python3.7/site-packages/openpyxl/writer/excel.py", line 276, in save
    self.write_data()
  File "/Users/emery/anaconda3/lib/python3.7/site-packages/openpyxl/writer/excel.py", line 76, in write_data
    self._write_worksheets()
  File "/Users/emery/anaconda3/lib/python3.7/site-packages/openpyxl/writer/excel.py", line 216, in _write_worksheets
    self.write_worksheet(ws)
  File "/Users/emery/anaconda3/lib/python3.7/site-packages/openpyxl/writer/excel.py", line 201, in write_worksheet
    writer.write()
  File "/Users/emery/anaconda3/lib/python3.7/site-packages/openpyxl/worksheet/_writer.py", line 357, in write
    self.write_tail()
  File "/Users/emery/anaconda3/lib/python3.7/site-packages/openpyxl/worksheet/_writer.py", line 345, in write_tail
    self.write_breaks()
  File "/Users/emery/anaconda3/lib/python3.7/site-packages/openpyxl/worksheet/_writer.py", line 241, in write_breaks
    self.xf.send(brk.to_tree())
AttributeError: 'tuple' object has no attribute 'to_tree'

My code (not this piece) is now failing on 16 other spreadsheets it previously worked on, and I suspect the problem is the same.

Comments (5)

  1. CharlieC

    Thanks for the report. I'd already come across this but the current fix doesn't solve all the problems.

  2. CharlieC

    Yeah, the problem is related to handling colBreaks as well as rowBreaks and then a typo in the dispatcher. Will be checking in a fix fairly shortly.

  3. emery@cs.umass.edu reporter

    Are you sure #1203 is a duplicate? It looks like a different error (but if it's a dupe and it'll be fixed soon, great!)

  4. Log in to comment