textRotation 255 prevents import
Created originally on Bitbucket by tcqwerty (Trevor Carlson)
In 2.1, a restriction of 0-180 was placed on text rotation, which is usually fine. However, 255 is also a valid value. Repro:
- Create a new Excel file (I'm using 2013)
- put some text in a random cell, and go to format cells->alignment.
- Under Orientation, click the vertical word "Text". This changes "Text" to white on black, and sets the vertical alignment to "Bottom (Indent)".
- Save, and try to open in openpyxl.
Traceback:
#!python
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Python27\lib\site-packages\openpyxl\reader\excel.py", line 151, in load_workbook
_load_workbook(wb, archive, filename, read_only, keep_vba)
File "C:\Python27\lib\site-packages\openpyxl\reader\excel.py", line 205, in _load_workbook
style_table, color_index, cond_styles = read_style_table(archive.read(ARC_STYLE))
File "C:\Python27\lib\site-packages\openpyxl\reader\style.py", line 215, in read_style_table
p.parse()
File "C:\Python27\lib\site-packages\openpyxl\reader\style.py", line 44, in parse
self.parse_cell_xfs()
File "C:\Python27\lib\site-packages\openpyxl\reader\style.py", line 191, in parse_cell_xfs
_style['alignment'] = Alignment(**alignment)
File "C:\Python27\lib\site-packages\openpyxl\styles\alignment.py", line 54, in __init__
self.textRotation = textRotation
File "C:\Python27\lib\site-packages\openpyxl\styles\hashable.py", line 54, in __setattr__
return object.__setattr__(self, *args, **kwargs)
File "C:\Python27\lib\site-packages\openpyxl\descriptors\__init__.py", line 89, in __set__
super(Min, self).__set__(instance, value)
File "C:\Python27\lib\site-packages\openpyxl\descriptors\__init__.py", line 68, in __set__
raise ValueError('Max value is {0}'.format(self.max))
ValueError: Max value is 180
Looking at the styles.xml, the resulting textRotation is, indeed, 255.