Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

How do I zip an XLSX file?

Select all of the outputted files/folders, right click, select 7-Zip, and select "Add to archive..." to create a new compressed file. 5. When the 7-Zip box shows up, select how to compress the file. To ensure that Excel can open it after this process is over, select "zip", leaving the other options as default.

How do I open an XLSX file with zip?

Xlsx files are just ZIP files, so you can simply unzip them right away using your favourite ZIP tool. Open your zip file tool, like for example, Winrar, find your excel file there, right-click on it, then you can simply "extract to a specified folder" and then your xml files will be saved there.

How do I read an XLSX file in Python?

The read_excel() function of pandas is used for reading the xlsx file. This function has used in the script to read the sales. xlsx file. The DataFrame() function has used here to read the content of the xlsx file in the data frame and store the values in the variable named data.

How do I fix a bad zip file in python?

In short: use 'zip -FF file. zip' to fix the file. It will restore the filelist.


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.


It's because you created empty .xlsx with no metadata which is an empty file with no cells formatting. use exel or equivalent spreadsheet software to save empty file in that directory, which will create an xlsx file with cell formating, after saving try to load file using openpyxl


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


I did something really stupid and got the same error. Basically, today was my first time trying this and I got it to work with the 'Automate' example and then tried my Excel. Didn't work! Took me a while to realize the error was due to having workbook password protected. The error doesn't match that at all, but when I removed the protection from the workbook, it worked! What can I say but 'duh' and 'yeah!'?


I'm late to the party, but I received the same error, but for different reasons.

On my mac, when I cut and pasted the .xlsx file into the directory I desired, it didn't actually place the file itself, it placed a symbolic link. That, for some reason, would raise the same error. I remedied this by opening the file, and using "save as".