python暴力破解excel密码,从密码保护的Excel文件到Python对象

本文介绍如何使用Python的win32com模块和pandas库,通过已知密码读取受保护的Excel文件,并将其内容保存为DataFrame。解决方案包括创建临时CSV文件,然后用pandas的read_csv函数读取。
摘要由CSDN通过智能技术生成

I am using Windows 7, Python 2.7 and Microsoft Excel 2013.

I know from here that I can open and access a password protected Excel sheet using the below sample code:

import sys

import win32com.client

xlApp = win32com.client.Dispatch("Excel.Application")

print "Excel library version:", xlApp.Version

filename, password = sys.argv[1:3]

xlwb = xlApp.Workbooks.Open(filename, Password=password)

# xlwb = xlApp.Workbooks.Open(filename)

xlws = xlwb.Sheets(1) # counts from 1, not from 0

print xlws.Name

print xlws.Cells(1, 1) # that's A1

I would like to save an Excel worksheet from a password protected file as a Python object. Ideally it would be saved as a pandas dataframe but I would be OK to have it as a dictionary or any other object type.

I have the passw

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值