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)'test.xlsx')

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

Comments (15)

  1. liuyuqian


  2. CharlieC

    Sorry but I can't read Mandarin. I suspect that the source file is from LibreOffice and is itself invalid.

  3. CharlieC

    What same problem? Looks like a duplicate of #647 to me but without any files and error messages in English I cannot investigate further.

  4. xxxxxxxiao

    I just simply load a xlsx file and then save it. Loading the xlsx file works find but when i called i had the same error as above

  5. xiaoqi7s reporter

    My file is exported by java and provided by developer so i guess that the file is LibreOffice.

  6. CharlieC

    Thanks for the file. The problem is somewhat related to the redundant styles that LibreOffice tends to create but I think I've fixed it.

  7. 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/", line 31, in __init__
        self._wb = openpyxl.load_workbook(filename)
      File "/opt/miniconda3/envs/klausur-tool/lib/python3.5/site-packages/openpyxl/reader/", line 238, in load_workbook
      File "/opt/miniconda3/envs/klausur-tool/lib/python3.5/site-packages/openpyxl/reader/", line 125, in parse
      File "/opt/miniconda3/envs/klausur-tool/lib/python3.5/site-packages/openpyxl/reader/", 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/", line 96, in __getitem__
        return self.styles[idx]
    IndexError: list index out of range
  8. CharlieC

    @skoslowski that looks like a separate issue. Please create a new ticket and provide a sample file.

  9. Log in to comment