密码保护的Excel文件 [英] Password Protected Excel File

查看:166
本文介绍了密码保护的Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个密码保护的excel电子表格。我需要打开这个电子表格并从中读取数据。我一直在尝试使用POI API无效。一个Java解决方案将是首选,但任何想法都将是有用的。



编辑:是的,我有密码。该文件在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆