Cell width setting crash since switching to 2.6.x

Issue #1274 resolved
Fabian Dill created an issue

So, this worked in 2.5.x:

    #simplified for issue
    def _set_optimal_width(self, sheet):
        for column_cells in sheet.columns:
            sheet.column_dimensions[column_cells[0].column].width = 40

It no longer does:

  File "E:\ConParser\output\xl.py", line 64, in _set_optimal_width
    sheet.column_dimensions[column_cells[0].column].width = 40
  File "C:\Program Files\Python37\lib\site-packages\openpyxl\utils\bound_dictionary.py", line 26, in __getitem__
    setattr(value, self.reference, key)
  File "C:\Program Files\Python37\lib\site-packages\openpyxl\descriptors\base.py", line 44, in __set__
    raise TypeError('expected ' + str(self.expected_type))
TypeError: expected <class 'str'>

I’ve looked over the changelog and found nothing that would indicate this change.

Comments (3)

  1. CharlieC

    I'm pretty sure this is the change in cell.column which is now the numerical index: this simplifies the programmatic access. Using cell.column_letter should fix things.

  2. Log in to comment