I have a site where users can upload Excel 2007 spreadsheets containing data which is extracted and processed overnight. Occasionally users will upload a password-protected file by accident. I'm aware that PHPExcel can't open files where the whole document
is password protected (i.e. the file cannot be opened without entering the password), and I can work around that restriction. However, is there a way that I can tell if a given file is password protected before trying to load the file for processing? At the
moment the initial loading code looks like this:
If the file is password protected, PHP prints lots of warnings before finally bailing out with a fatal error. Ideally I'd like to call a function before loading the file (e.g. isPasswordProtected($file_path)) or catch an exception.
$objReader = new PHPExcel_Reader_Excel2007();
$objPHPExcel = $objReader->load($file['file_path']);