import configparser
import os
import win32com.client
import turtle
import time
import math
import shutil
import threading
import sched
xcl = win32com.client.Dispatch("Excel.Application")
filename = ".//chenggong.xlsx"
try:
wb = xcl.Workbooks.Open(r"D:\myjupyter\自制python 脚本工具库\044 excel文件自动解密并去除密码\1.xlsx", False, False, None, "111")
xcl.DisplayAlerts = False
wb.SaveAs(filename, None, '', '')
wb.Save()
wb.Close(SaveChanges=True)
xcl.Quit()
except:
xcl.Quit()
import win32com.client
def get_sheetpw(xls,filename,password):
try:
xlsheet = xls.Workbooks.Open(filename, False, True, None, Password=password)
print('破解成功!')
print("文档密码是:{}".format(password))
xlsheet.Close()
return True
except:
return False
if __name__=='__main__':
xls = win32com.client.Dispatch("Excel.Application")
xls.DisplayAlerts=0
p=0
print('破解中......')
while True:
isdone=get_sheetpw(xls,r'D:\myjupyter\自制python 脚本工具库\044 excel文件自动解密并去除密码\文件.xlsx',p)
p=p+1
if isdone:
break
破解中......
破解成功!
文档密码是:123
import msoffcrypto
import io
import pandas as pd
temp= io.BytesIO()
with open("C://Users//wj//Desktop//3.xlsx","rb") as f:
excel = msoffcrypto.OfficeFile(f)
excel.load_key("1")
excel.decrypt(temp)
df = pd.read_excel(temp)
df