import openpyxl
def read_excel(excel_url,sheet_name):
# 加载工作簿
wb=openpyxl.load_workbook(excel_url)
# 获取sheet对象
sheet=wb[sheet_name]
# 打印最大行和列
# print(sheet.max_row,sheet.max_column)
# 行列表
row_list=[]
# 循环行
for row in range(2,sheet.max_row+1):
# print(row)
# 判断正向用例
if sheet.cell(row,7).value=='y':
col_list=[]
# 循环列
for column in range(1, sheet.max_column + 1):
# print(column)
# 保存到列里面
col_list.append(sheet.cell(row,column).value)
# print(col_list)
row_list.append(col_list)
print(row_list)
return row_list
openpyxl参数化
最新推荐文章于 2023-08-07 14:39:05 发布