Worksheet append not populating row_dimensions properly

Issue #379 resolved
CptJesus
created an issue

As the title says, using ws.append does not properly populate row dimensions.

To reproduce, you can use the following code:

from openpyxl import Workbook

wb = Workbook()
ws = wb.active
ws.append(['a', 'b', 'c'])
ws['A2'] = 4
ws['B2'] = 3
print vars(ws.row_dimensions[1])
print vars(ws.row_dimensions[2])

Output is:

{'index': 1, 'worksheet': None, 'collapsed': False, 'ht': None, 'outlineLevel': 0, 'hidden': False}
{'index': 2, 'worksheet': <Worksheet "Sheet">, 'collapsed': False, 'ht': None, 'outlineLevel': 0, 'hidden': False}

This breaks styling rows using the documented way of adding styles to rows, since the worksheet is None, resulting in an AttributeError.

Setting cells manually properly populates the worksheet variable, which is expected behavior.

Using the latest version of openpyxl from pip (2.1.2)

Comments (3)

  1. Log in to comment