Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [ ] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

pd.read_excel("path to file")

Issue Description

Hi! Since the update of openpyxl (31 january 2022) read_excel is no longer working properly to read excel files that have an active filter on them. With active filter i mean the filter function of excel where there is a selection active (for example one value in a column is excluded). Is there a method or way we can/argument to add in order to remove the auto filter from the file so that the file can be read again?

file from the pandas module where the error is found: site-packages/pandas/io/excel/_openpyxl.py error: Value must be either numerical or a string containing a wildcard

current version of pandas: 1.5.3 Version in which it worked from openpyxl 3.0.10 No longer working in latest two versions of openpyxl

Thank you in advance!

Expected Behavior

Read the file without the active filters so that all data is included

Installed Versions

INSTALLED VERSIONS ------------------ commit : 2e218d10984e9919f0296931d92ea851c6a6faf5 python : 3.9.5.final.0 python-bits : 64 OS : Linux OS-release : 5.4.0-1100-azure Version : #106~18.04.1-Ubuntu SMP Mon Dec 12 21:49:35 UTC 2022 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : C.UTF-8 LOCALE : en_US.UTF-8 pandas : 1.5.3 numpy : 1.20.3 pytz : 2021.3 dateutil : 2.8.2 setuptools : 58.0.4 pip : 21.2.4 Cython : 0.29.24 pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : 4.9.2 html5lib : None pymysql : None psycopg2 : 2.9.3 jinja2 : 2.11.3 IPython : 7.32.0 pandas_datareader: None bs4 : None bottleneck : None brotli : None fastparquet : None fsspec : None gcsfs : None matplotlib : 3.4.3 numba : None numexpr : None odfpy : None openpyxl : 3.1.1 pandas_gbq : None pyarrow : 7.0.0 pyreadstat : None pyxlsb : None s3fs : None scipy : 1.7.1 snappy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : 2.0.1 xlwt : None zstandard : None tzdata : None

Comment From: phofl

Hi, thanks for your report. Is this an intended feature from openpyxl? If no, you should probably open an issue there

Comment From: KiaraShannen

Hi, thanks for your report. Is this an intended feature from openpyxl? If no, you should probably open an issue there

Hi! Thank you for your quick response. Yes this was a conscious choice of openpyxl. Beneath you'll find the edit logs in which they keep the autofilter on the file as default table filter. In addition they do mention in their update that table filters are no longer overwritten.

https://foss.heptapod.net/openpyxl/openpyxl/-/commit/3af0b77f8a56820961e08e2e751026c984907a1d

Comment From: rhshadrach

I am not able to reproduce this, maybe I'm misunderstanding the issue. Here is my Excel file with row 3 filtered:

Pandas BUG: read_excel not working when filters are active and selected in worksheet

Then reading the file with openpyxl gives me all the data even though the filter is activated.

import openpyxl
print(openpyxl.__version__)
# 3.1.1
print(pd.read_excel('test.xlsx', engine='openpyxl'))
#    a  b  c
# 0  1  1  1
# 1  2  2  2
# 2  3  3  3

Comment From: KiaraShannen

Okay as you were not able to reproduce i checked and it only occurs with files that have an active filter and some values of rows are empty

test file i created on which i get the error: test_file_error.xlsx

Comment From: rhshadrach

Thanks for the example workbook. Running this, the ValueError I get is raised from site-packages/openpyxl/worksheet/filters.py. It appears to me this is an issue for openpyxl.

Comment From: phofl

Closing