密码保护的Excel文件

编程入门 行业动态 更新时间:2024-10-23 20:19:29
本文介绍了密码保护的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文件

本文发布于:2023-11-10 15:55:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575806.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:密码保护   文件   Excel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!