I have a program that generates reports with a large amount of data. I got things working properly using the Apache POI SXSSF to generate a xlsx file. http://poi.apache.org/spreadsheet/index.html
The thing that I couldn't find in their documentation is how to password protect the ENTIRE WORKBOOK. I want it so that if someone tries to open the file they need to enter a password in order to see the data.
Keep in mind that this is different than password protecting a single worksheet where they are still able to open the file and see the data but have read only access.
I didn't find anything in the SXSSFWorkbook documentation: https://poi.apache.org/apidocs/org/apache/poi/xssf/streaming/SXSSFWorkbook.html
Looks like there is a method for XSSFWorkbook called setWorkbookPassword but that doesn't exist for SXSSF and didn't work on the SXSSFWorkbook. https://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFWorkbook.html#setWorkbookPassword(java.lang.String,%20org.apache.poi.poifs.crypt.HashAlgorithm)
Anyone know how this can be done? Alternative workarounds will also be considered.
Thanks in advance.
UPDATE
I thought about maybe using a macro enabled workbook with script to password protect it as suggested here. Java Apache Poi SXSSF with Excel Macros
And I used the VBA code from here to do that: http://analysistabs.com/excel-vba/protect-unprotect-workbook/ and then use that file as a template when creating the Excel file but while I was playing around with the Macro it turns out it's not sufficient. Some computer security settings are set to "High" and will disable macros so when I opened the file, I did get a prompt for password but then I also got a warning message that said that Macros are disabled and I was able to view the workbook contents.
Any suggestions?