Detecting Password / Encrypted Files

Topics: Developer Forum, User Forum
Sep 13, 2011 at 7:33 PM


We currently use and are very happy with the excel library. When users try to upload file protected sheets it php excel generates thousands of notices and crashes php (due to memory), one user reported this issue ( but I'm not as interested in solving the notices as I am detecting if a file is password protected. The end goal being telling the user "Hey you can't user password protected files"


My question being, is there an easy way to detect if a file is password protected so that I can defensively code against a crash? If it's fairly simple, I wouldn't mind getting my hands dirty with the code, if I could be pointed in the right direction.



Sep 14, 2011 at 4:24 PM


I'm sorry, I don't have the answer to your question. I face same kind of issue with xlsm sheets that are not password protected. Protection is done at workbook level (users can't add/remove worksheets) and at worksheet level (users can't change sheet structure, add/remove lines/columns, able only to fill cell not locked). These files are used as templates to enter data that is later on loaded into a database.

Thanks a lot :)