读取excel报'xl/sharedStrings.xml' in the archive"
来源:10-5 项目实战之获取依赖数据
WHIFFET_7_Cadiz
2022-09-16
错误信息如下
老师, 我运行你的代码,然后提示如下错误,我按照百度,卸载了pycharm的excel reader插件,但是扔然报错 这个应该怎么处理呢
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "D:\Program Files\JetBrains\PyCharm Community Edition 2021.1.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "D:\Program Files\JetBrains\PyCharm Community Edition 2021.1.3\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:/009-群内资源分享/muke_unitest/imoocinterface/Util/handle_excel.py", line 116, in <module>
print(handle.get_rows_number('imooc_001'))
File "D:/009-群内资源分享/muke_unitest/imoocinterface/Util/handle_excel.py", line 92, in get_rows_number
cols_data = self.get_columns_value()
File "D:/009-群内资源分享/muke_unitest/imoocinterface/Util/handle_excel.py", line 77, in get_columns_value
columns_list_data = self.get_sheet_data()[key]
File "D:/009-群内资源分享/muke_unitest/imoocinterface/Util/handle_excel.py", line 24, in get_sheet_data
sheet_name = self.load_excel().sheetnames
File "D:/009-群内资源分享/muke_unitest/imoocinterface/Util/handle_excel.py", line 17, in load_excel
open_excel = openpyxl.load_workbook(base_path+"/Case/imooc.xlsx")
File "D:\Programs\Python\Python39\lib\site-packages\openpyxl\reader\excel.py", line 317, in load_workbook
reader.read()
File "D:\Programs\Python\Python39\lib\site-packages\openpyxl\reader\excel.py", line 277, in read
self.read_strings()
File "D:\Programs\Python\Python39\lib\site-packages\openpyxl\reader\excel.py", line 143, in read_strings
with self.archive.open(strings_path,) as src:
File "D:\Programs\Python\Python39\lib\zipfile.py", line 1502, in open
zinfo = self.getinfo(name)
**File "D:\Programs\Python\Python39\lib\zipfile.py", line 1429, in getinfo
raise KeyError(
KeyError: "There is no item named 'xl/sharedStrings.xml' in the archive"**
写回答
1回答
-
Mushishi
2022-09-16
你把你代码截图发一下,包没问题得情况下,这个错误大概率是因为你错误操作excel导致。
1、先确定你openpyxl是最新版本,版本没问题
2、确定你的excel文件能够正常打开,里面的sheet数据你能看到。
如果这两个没问题你操作excel的时候把excel文件关闭,然后运行代码。
00
相似问题