Closed tazjin closed 9 years ago
Hi Tazjin
Thanks a lot for the pull request, it is a really nice feature. I am thinking about how to streamline it for the general use case.
Let's say I want to load a spreadsheet, but I do not know whether or not it is encrypted. In that case, I see a couple of scenarios:
1) I try to load it, catch an exception if it is encrypted, prompt for a password and try to load it with the load-encrypted… function.
2) I call a test function to check whether or not the file is encrypted, then prompt for password as needed and load-encrypted…
3) I provide a higher-order function to the load function that will return a password (possibly prompting the user) if a password is needed.
4) I provide an overload for load-… that take a password, and this is then used if the workbook is encrypted, ignored otherwise.
I would like to make it easy on the application programmer so they don't need a lot of conditional logic to deal with this, yet flexible enough to allow it's use in both interactive and batch scenarios.
My preference is probably the overloads, a combination of 3 and 4.
In either case, it would probably be good to also add a function to test whether or not a (not loaded) spreadsheet file is encrypted or not.
Let me know what you think.
Thanks, Martin
Hej Martin!
The easiest solution would be, I think, to just add a test function that checks for encryption, then it's up to an application developer to handle it (or ignore it completely if they know they will never/always encounter encrypted files). This way you keep it simple and don't dictate too much application logic.
As for the implementation I'm a bit unsure because the encryption API of POI seems a bit strange to me in general.
//V
Hej Martin,
just wondering if you've had a chance to look at this / think about it?
//V
I have been away from this project, but I like your idea of adding a test function and an optional parameter to load with a password for the encrypted files (option 2 in the list above). If you would submit a pull for the latest version I would be happy to merge. Thanks, Martin
Adds a single function load-encrypted-workbook which, in addition to the filename, also takes a password argument.
Needed this because a document I have to import regularly now has password protection.