openpyxl 读取多个excle中的数据并保存到List中

def excel_to_json(file_name):
wb = load_workbook(file_name)
all_data = defaultdict(list)
for sheet_name in wb.sheetnames:
rows = list(wb[sheet_name].rows)
title = [i.value for i in rows[0]]
for row in rows[1:]:
data = [i.value for i in row]
all_data[sheet_name].append(dict(zip(title, data)))
return all_data
原文地址:https://www.cnblogs.com/xiaowandian/p/13182893.html