java代码实现对excel加密、解密(设置或去除打开密码)

时间:2022-08-22 23:09:29

本demo使用jxcell组件来完成对excel加密、解密的功能。

  jxcell.jar已破解,下载方式为关注下面二维码,回复jxcell或即可。

java代码实现对excel加密、解密(设置或去除打开密码)

具体代码如下:

import java.io.IOException;

import com.jxcell.CellException;
import com.jxcell.View; /**
* excel加密、解密 代码
*
* @author lifq
* @date 2015-3-13 下午02:13:24
*/
public class EncryptDecryptUtil { /**
* 读取excel,并进行加密
*
* @param url
* excel文件路径 例:D:\\word.xls
* @param pwd
* 加密密码
*/
public static void encrypt(String url, String pwd) {
View m_view = new View();
try {
// read excel
m_view.read(url);
// set the workbook open password
m_view.write(url, pwd);
} catch (CellException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} /**
* excel 解密
*
* @return void
* @author lifq
* @date 2015-3-13 下午02:15:49
*/
public static void decrypt(String url, String pwd) {
View m_view = new View();
try {
// read the encrypted excel file
m_view.read(url, pwd); // write without password protected
m_view.write(url);
} catch (Exception e) {
System.out.println(e.getMessage());
}
} public static void main(String args[]) {
// 下面1与2 两个方法请分开执行,可以看到效果
//
//1. 把g:\\test.xls 添加打开密码123
EncryptDecryptUtil.encrypt("g:\\test.xls", "123");
//2. 把g:\\test.xls 密码123 去除
EncryptDecryptUtil.decrypt("g:\\test.xls", "123"); }
}

加密后效果图:(打开时提示输入密码123)

java代码实现对excel加密、解密(设置或去除打开密码)

java代码实现对excel加密、解密(设置或去除打开密码)的更多相关文章

  1. php利用32进制实现对id加密解密

    前言 最近在项目中遇到一个问题,当前用户分享一个邀请码给好友,好友根据邀请码注册成为新用户之后,则成为当前用户的下级,特定条件下,可以得到下级用户的一系列返利.这里要实现的就是根据当前用户的id,生成 ...

  2. Java代码实现对Azkaban的Flow进行设置定时

    代码如下: public class CurlToAzkaban{ public static void scheduleExecute(String flow, String cronExpress ...

  3. C# 加密(Encrypt) 解密(Decrypt) 操作类 java与 C# 可以相互加密解密

    public sealed class EncryptUtils { #region Base64加密解密 /// <summary> /// Base64加密 /// </summ ...

  4. JAVA-----基于POI实现对Excel导入

    在日常项目开发中, 数据录入和导出是十分普遍的需求,因此,导入导出也成为了开发中一个经典的功能.数据导出的格式一般是excel或者pdf,而批量导入的信息一般是借助excel来减轻工作量,提高效率. ...

  5. 通过vb&period;net 和NPOI实现对excel的读操作

    通过vb.net 和NPOI实现对excel的读操作,很久很久前用过vb,这次朋友的代码是vb.net写的需要一个excel的操作, 就顾着着实现功能了,大家凑合着看吧 Option Explicit ...

  6. C&num;代码实现对HTTP POST参数进行排序

    private static string GetSortedParas(Dictionary<string, string> dic) { dic = dic.OrderBy(key = ...

  7. java DES转C&num;DES加密解密

    一个程序用到java的cn.core.jar加密的,需要在.NET 中解密,发现JAVA的des算法与C#的有点区别. 自己不太懂加密解密算法,所以找了个省事的方法,用IKVM.NET,用这个将cn. ...

  8. DES加密 java与&period;net可以相互加密解密两种方法

    DES加密 java与.net可以相互加密解密两种方法 https://www.cnblogs.com/DrWang/archive/2011/03/30/2000124.html sun.misc. ...

  9. 在Asp&period;Net MVC中使用NPOI插件实现对Excel的操作(导入,导出,合并单元格,设置样式,输入公式)

    前言 NPOI 是 POI 项目的.NET版本,它不使用 Office COM 组件,不需要安装 Microsoft Office,目前支持 Office 2003 和 2007 版本. 1.整个Ex ...

随机推荐

  1. 修改XML指定标签的内容

    修改Xml指定标签内容(我这是去掉指定标签内容的空格) 其实就是个很简单的方法,需要的盆友直接拿走. test.xml <?xml version="1.0" encodin ...

  2. JAVA 序列化

    一.概念 序列化:将对象转换为字节序列的过程. 反序列化:将字节序列恢复为对象的过程. 二.简单示例 package serialization; import java.io.Serializabl ...

  3. php 删除文件夹

    <?php // ./tp // ./tp/Public function deldir($dirname) { if(!file_exists($dirname)) { die("文 ...

  4. hdu 2196 Computer&lpar;树形DP&rpar;

    Computer Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  5. Selenium2Library系列 keywords 之 &lowbar;SelectElementKeywords 之 page&lowbar;should&lowbar;not&lowbar;contain&lowbar;list&lpar;self&comma; locator&comma; message&equals;&&num;39&semi;&&num;39&semi;&comma; loglevel&equals;&&num;39&semi;INFO&&num;39&semi;&rpar;

    def page_should_not_contain_list(self, locator, message='', loglevel='INFO'): """Veri ...

  6. MINA的session&period;close

    现象:客户端session.close之后,并没有提出,客户端程序一直hold在那里: 解决:调用了session.getService().dispose(false)方法后,客户端程序完成了退出 ...

  7. keybd&lowbar;event函数用法

    转自不用winio,直接达到驱动级模拟键盘效果的keybd_event函数用法 键盘模拟技术是在编写游戏外挂时经常使用的技术.但是由于很多游戏采用了directinput的方式,使得发送的一般键盘消息 ...

  8. selenium Chromediver

    Here we use wget to fetch the version number of the latest release, then plug the version into anoth ...

  9. hdu 4468 spy 极其精彩的一道kmp灵活运用题

    出的超级好的一道题.至于好在哪里,请思考题目: 题意抽象出来为给定一个字符串r,找出它的一个最短后缀s,使得这个r可以被 s的某前缀+s的某前缀+......+s的某前缀+s本身构造出来. 具体题目描 ...

  10. Git:fatal&colon; refusing to merge unrelated histories

    如何去解决fatal: refusing to merge unrelated histories 先pull,因为两个仓库不同,发现refusing to merge unrelated histo ...