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

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

问题描述

我有一个Excel US preadsheet受密​​码保护。我需要打开这个S preadsheet并从中读取数据。我一直在尝试使用POI API无济于事。一个Java的解决方案是pferred $ P $,但任何想法将是有益的。

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.

编辑:是的,我有密码。该文件是在Excel密码保护;一个必须输入密码来查看在S preadsheet。

Yes, I have the password. The file is password protected in excel; a password must be entered to view the spreadsheet.

EDIT2:我无法与密码POI打开它,我寻找一个替代的解决方案。

I am unable to open it with POI with the password, I am looking for an alternate solution.

推荐答案

您可以使用 JExcelApi的

它已经一段时间,因为我已经这样做了,所以我可能不会告诉你如何正确地做到这一点,但肯定是有办法做到这一点使用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天全站免登陆