密码保护的Excel文件 [英] Password Protected Excel File
问题描述
编辑:是的,我有密码。该文件在excel中受密码保护;必须输入密码才能查看电子表格。
编辑2:我无法使用密码打开POI,我正在寻找替代解决方案。 >
您可以使用 JExcelApi 。
自从我做完了以来已经有一段时间了,所以我可能不会告诉你如何正确地做,但绝对有一种方法使用JExcelApi执行此操作。尝试以下资源:
工作簿工作簿= Workbook.getWorkbook(新文件(/ path / to / protected.xls) );
workbook.setProtected(false);
WritableWorkbook copy = Workbook.createWorkbook(新文件(/ path / to / unprotected.xls),工作簿);
WritableSheet [] sheets = copy.getSheets();
(WritableSheet表:sheet){
sheet.getSettings()。setProtected(false);
}
copy.write();
copy.close();
当然,您将需要导入必需的类并捕获必要的异常。
I have an excel spreadsheet that is password-protected. I need to open this spreadsheet and read the data from it. I've been attempting to use the POI API to no avail. A Java solution would be preferred but any ideas would be helpful.
Edit: Yes, I have the password. The file is password protected in excel; a password must be entered to view the spreadsheet.
Edit2: I am unable to open it with POI with the password, I am looking for an alternate solution.
You can use JExcelApi.
It has been a while since I have done this, so I may not be telling you how to do it correctly, but there is definitely a way to do this using JExcelApi. Try the source below:
Workbook workbook = Workbook.getWorkbook(new File("/path/to/protected.xls"));
workbook.setProtected(false);
WritableWorkbook copy = Workbook.createWorkbook(new File("/path/to/unprotected.xls"), workbook);
WritableSheet[] sheets = copy.getSheets();
for (WritableSheet sheet : sheets){
sheet.getSettings().setProtected(false);
}
copy.write();
copy.close();
Of course, you will need to import necessary classes and catch necessary exceptions.
这篇关于密码保护的Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!