Conditional Formatting MultiCellRange TypeError
Created originally on Bitbucket by brennanb414 (Brennan Brown)
Trying to apply conditional formatting to an entire column using "A:A" but it fails with a MultiCellRange TypeError.
C:\Users\bbrown\Desktop>python openpyxltest.py
Traceback (most recent call last):
File "C:\Users\bbrown\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\descriptors\base.py", line 57, in _convert
value = expected_type(value)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\bbrown\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\descriptors\base.py", line 57, in _convert
value = expected_type(value)
File "C:\Users\bbrown\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\worksheet\cell_range.py", line 381, in __init__
ranges = [CellRange(r) for r in ranges.split()]
File "C:\Users\bbrown\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\worksheet\cell_range.py", line 381, in <listcomp>
ranges = [CellRange(r) for r in ranges.split()]
File "C:\Users\bbrown\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\worksheet\cell_range.py", line 58, in __init__
self.min_row = min_row
File "C:\Users\bbrown\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\descriptors\base.py", line 107, in __set__
value = _convert(self.expected_type, value)
File "C:\Users\bbrown\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\descriptors\base.py", line 59, in _convert
raise TypeError('expected ' + str(expected_type))
TypeError: expected <class 'int'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "openpyxltest.py", line 9, in <module>
ws.conditional_formatting.add('A:A',ColorScaleRule(start_type='percentile', start_value=10, start_color='F8696B', mid_type='num', mid_value=0, mid_color='FFFFFF', end_type='percentile', end_value=90, end_color='63BE7B'))
File "C:\Users\bbrown\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\formatting\formatting.py", line 75, in add
cf = ConditionalFormatting(range_string)
File "C:\Users\bbrown\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\formatting\formatting.py", line 33, in __init__
self.sqref = sqref
File "C:\Users\bbrown\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\descriptors\base.py", line 69, in __set__
value = _convert(self.expected_type, value)
File "C:\Users\bbrown\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\descriptors\base.py", line 59, in _convert
raise TypeError('expected ' + str(expected_type))
TypeError: expected <class 'openpyxl.worksheet.cell_range.MultiCellRange'>
This works fine in 2.4.8 but started failing when I updated. It also works with a defined range like 'A1:A10'
File was created with Microsoft Excel and I am running on windows 10.
Attachments: openpyxltest.pytestwb.xlsx