How to deal with warning : "Workbook contains no default style, apply openpyxl's default "

I have the -current- latest version of pandas, openpyxl, xlrd.

openpyxl : 3.0.6.
pandas : 1.2.2.
xlrd : 2.0.1.

I have a generated excel xlsx- file (export from a webapplication).
I read it in pandas :

myexcelfile = pd.read_excel(easy_payfile, engine="openpyxl")

Everything goes ok, I can successfully read the file.
But I do get an ugly warning :

/Users/*******/projects/environments/venv/lib/python3.8/site-packages/openpyxl/styles/stylesheet.py:214: UserWarning: Workbook contains no default style, apply openpyxl's default
  warn("Workbook contains no default style, apply openpyxl's default")

The documentation doesn't shed too much light on it. Is there any way I can add an option to avoid this warning. I prefer not to suppress it.

Thanks!


I don't think the library offers you a way to disable this thus you are going to need to use the warnings package directly.

A simple and punctual solution to the problem would be doing:

import warnings

with warnings.catch_warnings(record=True):
    warnings.simplefilter("always")
    myexcelfile = pd.read_excel(easy_payfile, engine="openpyxl")

@ruhanbidart solution is better, but if you have dozens of calls to pd.read_excel, you can simply:

import warnings
warnings.simplefilter("ignore")

I had the exact same warning and was unable to read the file. In my case the problem was coming from the Sheet name in the Excel file.

The initial name contained a . (ex: MDM.TARGET) I simply replace the . with _ and everything's fine.


df=pd.read_excel("my.xlsx",engine="openpyxl") passing the engine parameter got rid of the warning for me. Default = None, so I think it is just warning you that it using openpyxl for default style.