Attempting to access font attribute of existing cell with default formatting causes error
Created originally on Bitbucket by jordan_macdonald (Jordan Macdonald)
One of my scripts which uses openpyxl to read data from an existing spreadsheet has stopped working after I upgraded to 2.3. The error occurs when I try to access the font property of a cell in order to check that it is not struck-through (strike-through being used to flag a cell to be skipped). The relevant section of the stack trace:
File "C:\Users\jordan_macdonald\[REDACTED]", line 27, in __init__
if (cell is None or cell.value is None or cell.font.strike):
File "C:\Python27\lib\site-packages\openpyxl-2.3.0b2-py2.7.egg\openpyxl\cell\read_only.py", line 81, in font
_id = self.style_array.fontId
AttributeError: 'NoneType' object has no attribute 'fontId'
Other than the possible strike-through, the cell in question is has no formatting specified in the source spreadsheet; I presume the error is caused because the new style management code fails to specify a default Font object for cells in the default format.