python 读取整个excel表内容的方法

方法一:
读取指定列的内容
def ReadCheckUrlOriData(sheetname):
listori = []
wb = openpyxl.load_workbook(excelpath)
checkUrlSheet = wb[sheetname] #打开指定sheet

#读取数据到listori中
for row1 in range(2,500):           #2,500是excel中数据的行
    listori.append(checkUrlSheet.cell(row=row1,column=3).value)

return listori

方法二:
读取整个excel的内容
def ReadOriData(sheetname):
listori = []
wb = openpyxl.load_workbook(excelpath)
wsoridata = wb[sheetname] #原始数据sheet
# #读取原始数据到listori中
for row in wsoridata.rows:
for cell in row:
listori.append(cell.value)
return listori

转载于:https://www.jianshu.com/p/e34e99a63d0b

猜你喜欢

转载自blog.csdn.net/weixin_34348174/article/details/91185087