密码保护的java中的xls / xlsx文件 [英] Password protected xls/xlsx file in java
问题描述
我已经创建了受密码保护的zip文件,该文件在此 http://的帮助下有xls文件java.sys-con.com/node/1258827 。
I have created password protected zip file which has xls file with the help of this http://java.sys-con.com/node/1258827.
我的问题是,是否有任何java api会创建受密码保护的xls文件而不是zip文件。
我想在xls文件上直接应用密码。加密/解密是一个选项,但想要在双击文件时提示。
My question is ,Is there any java api which will create password protected xls file instead of zip file. I want to directly apply password on xls file.Encryption/Decryption is the option but want to prompt when when double clicked on file.
编辑:
我得到了这个
HSSFSheet.protectSheet(xyz);
但它只使表格只读。
edit:
I got this
HSSFSheet.protectSheet("xyz");
but it only makes sheet read only.
即使我试过这个 hssfworkbook.writeProtectWorkbook(abc,abc);
但它没有提示用于密码。
Even I have tried this hssfworkbook.writeProtectWorkbook("abc", "abc");
but its not prompting for password.
Edit1: org.apache.poi.hssf.record.crypto.Biff8EncryptionKey
包中有方法打开密码保护的excel文件 org.apache.poi.hssf.record.crypto.Biff8EncryptionKey.setCurrentUserPassword(密码);
是否有任何方法可以在不受保护的情况下设置密码excel文件?
There is the method in org.apache.poi.hssf.record.crypto.Biff8EncryptionKey
package to open password protected excel file org.apache.poi.hssf.record.crypto.Biff8EncryptionKey.setCurrentUserPassword(password);
Is there any method to set password on unprotected excel file?
Edit2:
我试过JExcel API
I tried JExcel API
工作簿w =工作簿.getWorkbook(new file(c:\\employees22533.xls));
Sheet ws = null;
ws = w.getSheet(Employee List) ;
SheetSettings sh = ws.getSettings();
sh.setPassword(abc);
但它没有设置任何密码
推荐答案
我个人使用 JExcelApi
但我不记得曾见过有关密码保护的内容。就 JExcelApi
而言,有许多功能,其答案被称为否:
I've personally used JExcelApi
but I do not remember having seen something about password protection into it. As far as JExcelApi
is concerned there are a number of features where the answer is known to be "No":
- 数据透视表
- 下拉列表
- 单元格中的富文本
- 设置重复行
- 密码保护
- Pivot Tables
- Dropdown Lists
- Rich Text in cells
- Set repeating rows
- Password Protection
我个人认为如果密码保护是可能的(使用开源api)
他们将在互联网上提供很多教程,你可以通过快速谷歌搜索搜索它们,不幸的是,没有一个免费提供的Java电子表格API似乎支持编写加密的电子表格。
I personally think that if Password Protection would've been possible(with open source api's) Their would be a lot of tutorials available on internet and you could search them simply by a quick Google search, Unfortunately none of the freely available Java spreadsheet APIs seems to support writing encrypted spreadsheets.
但是如果您愿意使用商业API /库,请参阅这个
However If you're willing to use commercial api/library then see this
这篇关于密码保护的java中的xls / xlsx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!