Tried with 2.0.4
from openpyxl.cell import get_column_letter from openpyxl.styles import Style, NumberFormat from openpyxl.workbook import Workbook wb = Workbook(optimized_write=True) ws = wb.create_sheet() ws.append(['Pro', '15 %']) ws['B1'].style = Style(number_format=NumberFormat('0%'))
Traceback (most recent call last): File "x.py", line 9, in <module> ws['B1'].style = Style(number_format=NumberFormat('0%')) File "/var/www/BIS-trunk/venv-latest/lib/python2.6/site-packages/openpyxl/cell/cell.py", line 423, in style return self.parent.set_style(self.coordinate, new_style) File "/var/www/BIS-trunk/venv-latest/lib/python2.6/site-packages/openpyxl/worksheet/worksheet.py", line 430, in set_style self._styles[coordinate] = self.parent.shared_styles.add(style) TypeError: list indices must be integers, not str
While it's true it is an end user error, it took me some time to figure out the problem was that I was attempting to modify an optimized write workbook, which of course cannot be modified by definition.
Would have been nice to get a CannotModifyOptimizedWorkbookError raised instead