我昨天使用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
如果有人对如何解决它有任何线索,将不胜感激。谢谢