我正在阅读现有的xlsx工作表并使用openpyxl将数据写入其中,但是对于阅读工作表我使用'load_workbook'是从现有xlsx文件获取工作表的正确方法,它显示错误
我这样做的错误:
Traceback (most recent call last):
File "C:\Users\USER\Documents\Scripts\Practice\ExcelRead.py", line 78, in <module>
wb = load_workbook(filename = 'Copy.xlsx', use_iterators = True)
File "C:\Python27\lib\site-packages\openpyxl\reader\excel.py", line 141, in load_workbook
archive = ZipFile(f, 'r', ZIP_DEFLATED)
File "C:\Python27\lib\zipfile.py", line 770, in __init__
self._RealGetContents()
File "C:\Python27\lib\zipfile.py", line 811, in _RealGetContents
raise BadZipfile, "File is not a zip file"
BadZipfile: File is not a zip file
如何读取和写入现有的XLSX表格我在这里使用了openpyxl,但没有写入该表格
答案 0 :(得分:0)
您是否尝试将excel文件和.py文件存储在同一文件夹中,然后执行wb = load_workbook('Copy.xlsx')