xlsx and xlsm files return badzipfile: file is not a zip file

前端 未结 13 1508
灰色年华
灰色年华 2020-12-30 05:48

I\'m trying to open both an xlsx file and an xlsm file both give me the same error

badzipfile: file is not a zip file

here is wh

相关标签:
13条回答
  • 2020-12-30 06:30

    If you call openpyxl.load_workbook with file-like object, be sure to open it in binary mode.

    0 讨论(0)
  • 2020-12-30 06:30

    The xlsx file may have password and you are not granted to access. Delete the password and you can use openpyxl.load_workbook() to access it.

    0 讨论(0)
  • 2020-12-30 06:32

    I have been facing this error for a while and so i just uninstalled openpyxl and reinstall version 2.6.3 and it worked well. This might help you too, no need to change anything just run these commands using pip

    pip uninstall openpyxl
    
    pip install openpyxl==2.6.3
    

    Hope it helps you.

    0 讨论(0)
  • 2020-12-30 06:33

    I had the same problem. It is because the file I was trying to open in Python was already running. You need to check if the file you are trying to open in Python is not running in tasks.

    0 讨论(0)
  • 2020-12-30 06:34

    The same problem occurred to me, and then I noticed the following:

    When I created the .xlsx file from file manager, by creating new document with .xlsx format, I had the same error. But when I created the file with some spreadsheet software (libreoffice-calc) in my case, it just worked fine. I hope this may help.

    0 讨论(0)
  • 2020-12-30 06:35

    This also happened to me when I pointed openpyxl to an alias of the file instead of the original file.

    0 讨论(0)
提交回复
热议问题