How to solve xlrd error: Excel xlsx file not supported error in Excel
A free Office suite fully compatible with Microsoft Office
Pandas provide methods to read different file formats using a single line of code. When reading an xlsx file, rd.biffh.XLRDError: Excel xlsx file; not supported error might occur. You can solve xlrd.biffh.XLRDError: Excel xlsx file; not supported Error by updating the Pandas library version to the latest version.
Now let us see the reason for this error and how to solve it.
Reason for the Error
The Pandas cannot open an Excel (.xlsx) file when you use the read_excel() method available in the Pandas library version earlier than V1.2.0. Because the versions older than 1.2.0 internally use the xlrd library to read the excel files. The xlrd library supports ONLY reading the .xls files. It doesn't support reading the .xlsx or .xlsm files any longer. Hence, you need to use a different approach to solve this problem.
Solution 1 for solving xlrderror excel xlsx file not supported error
You can solve the xlrd.biffh.XLRDError: Excel xlsx file; not supported error by upgrading the Pandas version to the latest version.
1) By default, the latest version uses the openpyxl library. This library supports reading the .xlsx file and .xlsm files.
To know the current Pandas library version, use the below Code.
2) You can upgrade the Pandas libraryto the latest version using the below statement.
Prefixing the % in PIP lets you update the packages directly from Jupyter
3) The Pandas library is upgraded to the latest version, and also the dependent libraries are updated. With the latest library, you can use the read_excel() method directly to read the excel files. Use the code below to read the xlsxfile or xlsm
4) The file will be read, and the data frame will be populated. You can print the data frame to see the values in the excel file.
Data frame Will Look Like
5) This is how you need to solve the xlrd.biffh.XLRDError: Excel xlsx file; not supported Error.
Solution 2 to solve xlrderror excel xlsx file not supported error
You can use the openpyxl engine to read the xlsx file. This is an alternate way to solve the xlrderror excel xlsx file not supported error. If you do not want to upgrade the Pandas library to the latest version, you shall use this solution. However, it is always recommended to use the latest library versions to avoid security threats to your application.
Following are the steps to solve the error
Use openpyxl to open .xlsx files instead of xlrd.
Install the openpyxl library on your cluster.
Confirm that you are using pandas version 1.0.1 or above.
Specify openpyxl when reading .xlsx files with pandas.
Pandas cannot open an Excel (.xlsx) file using the read_excel() method when you’re using the Pandas version earlier than V1.2.0
Did you learn how to solve xlrderror excel xlsx file not supported error in excel? You can follow WPS Academy to learn more features of Word Document, Excel Spreadsheets, and PowerPoint Slides.
You can also download WPS Office to edit the word documents, excel, PowerPoint for free of cost. Download now! And get an easy and enjoyable working experience.