使用python讀取excel的列或者行
阿新 • • 發佈:2020-12-25
使用python讀取excel的列或者行,參考使用 都有備註 需要使用opepyxl模組
import os
from openpyxl import load_workbook
wb=load_workbook(r"C:\Users\dell\Desktop\新建 Microsoft Excel 工作表.xlsx") #表格檔名
sheet=wb["1"] #表名
#print("最大行:{0}".format(sheet.max_row)) #數表格最大行
#print ("最大行:{0}".format(sheet.max_column)) #數表格最大列
dict1= list(range(1,32)) #列或行從第幾個到第幾個
for dict2 in dict1:
res = sheet.cell(dict2,7).value #res = sheet.cell(輸入行數的數字,輸入格子列數的數字)
print(res)