Vague CFSpreadsheet POIFSFileSystem error message
For what it's worth, the inclusion of CFSpreadsheet and all the associated functions in ColdFusion 9 is a very welcome update. It's enabled me to generate some very complex and impressively formatted documents with relative ease.
One thing I'm working on requires my client to send me import data spreadsheets that I run through the new application (in development) and pull into the database. One particular file happened to have a password associated with reading it - total brain fart that I missed this. I even opened it previously when first receiving it with the password and it didn't twig. So duh to me.
Anyway, using CFSpreadsheet to read this file in quickly ends with the error response:
An error occurred while reading the Excel: java.lang.IllegalArgumentException: The supplied POIFSFileSystem does not contain a BIFF8 'Workbook' entry. Is it really an excel file?.
Oh as a side note, I love how the error message actually asks me a question. It's like it has a sense of humour. I even attempted opening the file in WinRar and got an error message that was just as vague.
As you can see it's not really the most helpful of error messages but to cut a long story short it is the result of the file have password protection. I would have assumed that a password protected file would come back with an authentication error message, but maybe the POI libraries are vague on this when throwing the error. I imagine maybe the data is encrypted which is not recognised until Excel loads the contents of the file, hence prompting you to enter a password. Who knows.
Oddly, it seems that write and update actions for CFSpreadsheet have attributes for using a password, but not read. Anyone please let me know otherwise as it would be helpful (CF9 Docs http://goo.gl/QDwM).
So, the lesson learnt. Yes, always check "Is it really an excel file?" and of course keep in mind that password protected files might also cause vague misleading error response messages. It does make sense of course than error would be thrown and I should have checked first to see if the file had a password first. That would have solved my problem right off the bat!


