'get excel file header and check if valid excel file

I have a very weird situation in which sometimes I will have valid excel and some times like this

enter image description here

so In case of these randoms I will discard and won't process this . So is there any way to do this ?

and 2nd thing how I can print all headers currently I am getting this

df = pd.read_excel(file_name.xlsx , sheet_name=key)
print(df.head()) 

but it's not printing headers



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source