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}")
相关推荐
nothing&nowhere5 分钟前
用 Python 做问卷数据清洗:无效样本检测与处理实战
开发语言·python·数据清洗·数据处理·问卷星·问卷星脚本·刷问卷
青瓦梦滋10 分钟前
协议定制/序列化-反序列化(Linux视角)
linux·服务器·网络·c++
花酒锄作田18 分钟前
如何发布自己的 Python 库到 PyPI
python
researcher-Jiang41 分钟前
Design Patterns——Template Method入门到情景实战
python·设计模式·模板方法模式
阿成学长_Cain3 小时前
Linux dirs命令详解|Bash目录堆栈管理快速切换目录实战教程
linux·运维·前端·数据库
ICECREAM4 小时前
Linux 进程间通讯(IPC)——总结
linux
飞猪~4 小时前
LangChain python 版本 第一集
开发语言·python·langchain
想你依然心痛5 小时前
嵌入式Linux安全加固:SELinux、Capabilities与Seccomp——强制访问控制与沙箱
linux·运维·安全
2601_956319885 小时前
最新AI量化提效,先做可验证的小流程
人工智能·python