安裝
pip3 install xlrd
用法
Sheet編號從0開始
rows,colnum編號均從0開始
合並的單元格僅返回第一格內容
Sheets只能被調用一次,可獲取所有sheet取idx
無論表格內數據類型是int還是str,純數字內容會返回float
示例
import xlrd
file = "name_list.xls"
data = xlrd.open_workbook(file)
table = data.sheets()#Read all sheet by idx
table_1 = table[1] #Input signal sheet
name = table_in.col_values(2, start_rowx=1, end_rowx=None) #Get col.C w/o header
print(name) #output ['Ada','Barry','Colin','Darwin']
table_2 = table[2] #Next sheet
...
注意
py文件名不可以命名為xlrd否則會與import沖突報錯AttributeError: module 'xlrd' has no attribute 'open_workbook'