import os, sys
import win32com.client
import time
import hashlib
import tkinter as tk #调用GUI图形模块
from tkinter import filedialog
def pwd_xlsx(old_filename,new_filename,pwd_str,pw_str=''):
xcl = win32com.client.Dispatch("Excel.Application")
# pw_str为打开密码, 若无 访问密码, 则设为 ''
wb = xcl.Workbooks.Open(old_filename, False, False, None, pw_str)
xcl.DisplayAlerts = False
# 保存时可设置访问密码.
wb.SaveAs(new_filename, None, pwd_str, '')
time.sleep(0)
wb.Close()
xcl.Quit()
def read_path(path):
dirs = os.listdir(path)
return dirs
def get_file(data_dir):
f = open(data_dir,'r')
filelist = f.readlines()
f.close()
filename_l=[]
print(filelist)
&nb

该博客介绍了一个使用Python进行Excel文件加密的方法。通过win32com.client库与Excel应用程序交互,实现了读取Excel文件并设置访问密码的功能。文章还提供了选择文件夹的图形界面,以便批量加密Excel文件。用户可以自定义新密码,并通过程序将密码应用到选定的Excel文件上。
最低0.47元/天 解锁文章

1170

被折叠的 条评论
为什么被折叠?



