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

zw1ck picture zw1ck · Nov 23, 2015 · Viewed 26.3k times · Source

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 what I'm typing:

import openpyxl
wb=openpyxl.load_workbook('c:\\users\\me\\documents\\filename.xlsm', keep_vba=True)
wb2=openpyxl.load_workbook('c:\\users\\me\\documents\\filename2.xlsx')

both load_workbook commands result in the same error. They both exist at that location. why am I getting this error?

Answer

user5449023 picture user5449023 · Jan 23, 2016

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.