首页 > 解决方案 > Openpyxl 2.5.11 版本问题

问题描述

我昨天用 Openpyxl 库更新到 2.5.11 版。现在,当我只是打开一个 excel 工作簿(它是一个没有宏的 xlsx 文件)时,我收到以下奇怪的错误消息,我昨天在更新库之前打开完全相同的文件时没有:代码:

tips = r"NTipsPerf6b.xlsm"
wb = openpyxl.load_workbook(tips)

这是回溯:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-16-980c37a8c9f7> in <module>()
----> 1 wb = openpyxl.load_workbook(tips)

C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\reader\excel.py in load_workbook(filename, read_only, keep_vba, data_only, guess_types, keep_links)
    291         ws._rels = [] # reset
    292 
--> 293     parser.assign_names()
    294 
    295     #wb._differential_styles.styles =  [] # tables may depened upon dxf

C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\packaging\workbook.py in assign_names(self)
    104             reserved = defn.is_reserved
    105             if reserved in ("Print_Titles", "Print_Area"):
--> 106                 sheet = self.wb._sheets[defn.localSheetId]
    107                 if reserved == "Print_Titles":
    108                     rows, cols = _unpack_print_titles(defn)

IndexError: list index out of range

如果有人对如何解决它有任何线索,将不胜感激。谢谢

标签: python-3.xopenpyxl

解决方案


推荐阅读