Detecting corrupted excel file and generates error logs if the excel file is corrupted

How to detect corrupted excel file and generates error logs if the excel file is corrupted?