Call save,Prompt list index out of range

Issue #781 resolved
xiaoqi7s
created an issue

import openpyxl path = r'C:\Users\hcb\Desktop\test.xlsx' wb = openpyxl.load_workbook(path) wb.save('test.xlsx')

Traceback (most recent call last): File "D:/python3/test1/myPackge/test2.py", line 4, in wb.save('test.xlsx') File "C:\Python36\lib\site-packages\openpyxl\workbook\workbook.py", line 342, in save save_workbook(self, filename) File "C:\Python36\lib\site-packages\openpyxl\writer\excel.py", line 267, in save_workbook writer.save(filename) File "C:\Python36\lib\site-packages\openpyxl\writer\excel.py", line 248, in save self.write_data() File "C:\Python36\lib\site-packages\openpyxl\writer\excel.py", line 81, in write_data self._write_worksheets() File "C:\Python36\lib\site-packages\openpyxl\writer\excel.py", line 197, in _write_worksheets xml = ws._write() File "C:\Python36\lib\site-packages\openpyxl\worksheet\worksheet.py", line 870, in _write return write_worksheet(self) File "C:\Python36\lib\site-packages\openpyxl\writer\worksheet.py", line 99, in write_worksheet cols = ws.column_dimensions.to_tree() File "C:\Python36\lib\site-packages\openpyxl\worksheet\dimensions.py", line 230, in to_tree obj = col.to_tree() File "C:\Python36\lib\site-packages\openpyxl\worksheet\dimensions.py", line 182, in to_tree attrs = dict(self) File "C:\Python36\lib\site-packages\openpyxl\worksheet\dimensions.py", line 51, in iter value = getattr(self, key, None) File "C:\Python36\lib\site-packages\openpyxl\styles\styleable.py", line 95, in get return coll.names[idx] IndexError: list index out of range

Comments (14)

  1. Sebastian Koslowski

    Unfortunately, I seem to now get a possibly related error when loading a file:

      File "/home/koslowski/code/klausur_tool/cel_klausur_tool/database/exam.py", line 31, in __init__
        self._wb = openpyxl.load_workbook(filename)
      File "/opt/miniconda3/envs/klausur-tool/lib/python3.5/site-packages/openpyxl/reader/excel.py", line 238, in load_workbook
        ws_parser.parse()
      File "/opt/miniconda3/envs/klausur-tool/lib/python3.5/site-packages/openpyxl/reader/worksheet.py", line 125, in parse
        dispatcher[tag_name](element)
      File "/opt/miniconda3/envs/klausur-tool/lib/python3.5/site-packages/openpyxl/reader/worksheet.py", line 287, in parser_conditional_formatting
        rule.dxf = self.differential_styles[rule.dxfId]
      File "/opt/miniconda3/envs/klausur-tool/lib/python3.5/site-packages/openpyxl/styles/differential.py", line 96, in __getitem__
        return self.styles[idx]
    IndexError: list index out of range
    
  2. Log in to comment