How to password protect a zipped Excel file in Java?

你离开我真会死。 提交于 2019-11-30 21:42:47
Prashant Bhate

Without uncompressing, Its impossible to password protect excel which is inside a zip file.

Here is what you can do

Piotr Gwiazda
  • Use java.util.zip or zip4j to decompress file to some temp direcotry or to memory, if you know it's small.
  • Then use HSSFWorkbook.writeProtectWorkbook from Apache POI library
  • Compress Excel workbook again.

I think you should check out truezip (Truezip website). It provides read/write access to ZIP, JAR, EAR, WAR etc and supports appending to existing ZIP files.

I suggest you create your zip file without the excel file in it, create your passworded excel file as directed in the link you provided and then use truezip to write this excel file to the archive. Hope this helps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!