用python讀取帶密碼的excel文件中的數據,程序代碼如下:
#filename:readingxls.py
'''
此程序的作用為:用python讀取帶密碼的excel文件中的數據。
首先通過pip安裝xlrd第三方庫 pip3 install xlrd
請輸入excel文件路徑:D:\x1.xls
'''
import xlrd
path=input("請輸入excel文件路徑:")
workbook=xlrd.open_workbook(path)
b=len(workbook.sheets())
i=0
for i in range(b):
sheet=workbook.sheet_by_index(i)
for row in range(sheet.nrows):
print()
for col in range(sheet.ncols):
print("%7s"%sheet.row(row)[col].value,'\t',end='')
print()