import pandas as pd
# pandas==1.2.4
def process_data(filename, sheet_names, out_filename):
"""
读取目标表格文件中的sheet,合并写到out_filename中
:param filename: str
:param sheet_names: list
:param out_filename: str
:return:
"""
writer = pd.ExcelWriter(out_filename)
df = [pd.read_excel(filename, sheet_name=sheet_name) for sheet_name in sheet_names]
for index in range(len(df)):
df[index].to_excel(excel_writer=writer, sheet_name=sheet_names[index])
writer.save()
process_data(filename='xxx.xlsm', sheet_names=['xxx', 'xxx', 'xxx'], out_filename='xxx.xlsx')