def read_data_from_excel(excel_file,sheet_name):
return_value=[]
#判断文件是否存在
if not os.path.exists(excel_file):
raise ValueError("File not exists")
#打开指定的sheet
wb=load_workbook(excel_file)
for s in wb.sheetnames:
if s==sheet_name:
sheet = wb[sheet_name]
for row in sheet.rows:
return_value.append([col.value for col in row])
print(return_value)
return return_value[1:]

posted on 2021-07-18 17:23  悟奕  阅读(248)  评论(0编辑  收藏  举报