python自动移除excel文件密码(小工具)

安装 msoffcrypto-tool

使用pip命令安装: 打开命令行工具(如终端、命令提示符或Powershell),然后输入以下命令来安装msoffcrypto-tool:
pip install msoffcrypto-tool库,进行自动移除excel文件密码

python 复制代码
import msoffcrypto

# 已加密Excel文件路径
encrypted_file = "F:\解密前.xlsx"
# 未加密文件将保存的路径
unencrypted_file = "F:\解密后.xlsx"
# Excel文件密码
excel_password = "密码"

# 打开加密文件
with open(encrypted_file, "rb") as encrypted_file_fd:
    office_file = msoffcrypto.OfficeFile(encrypted_file_fd)

    # 使用密码解密
    office_file.load_key(password=excel_password)

    # 将解密内容写入新文件
    with open(unencrypted_file, "wb") as unencrypted_file_fd:
        office_file.decrypt(unencrypted_file_fd)

print(f"文件已解密并保存至:{unencrypted_file}")
相关推荐
binqian1 分钟前
【linux】OpenSSH升级文档
linux·运维·网络
吴声子夜歌8 分钟前
Shell编程——if条件语句
linux·运维·shell
晓窗科技12 分钟前
口碑好的AI基座服务商
大数据·人工智能·python
Dawn-bit31 分钟前
Linux 运维基础扩展:跳板机、堡垒机与物理服务器全流程
linux·运维·服务器·云计算·运维开发
小灰灰搞电子39 分钟前
Python 信号量详解:并发控制实战
python·信号量
新时代牛马42 分钟前
Linux 定时任务:crontab、anacron 与systemd timer
linux·运维·服务器
新时代牛马1 小时前
cyclictest 毛刺从哪来?从ftrace、latencytop、perf到IRQ/调度延迟定位
android·开发语言·python·kotlin
mounter6251 小时前
Linux 7.2 引入更灵活的块设备错误注入机制
linux·linux kernel·kernel·disk·error injection
Dxy12393102161 小时前
Python如何结合AI解决数据分析问题
人工智能·python·数据分析
cpolar技术支持1 小时前
Docker 容器启动失败怎么查?端口、日志、权限与网络排障完整教程
linux·docker·容器·cpolar·网络排障