import os
from openpyxl import Workbook, load_workbook
import re
import shutil
def copy_data():
wb = Workbook()
for name in os.listdir(r'./办公自动化/files'):
# print(name)
if re.findall('xlsx', name):
# print(name)
path = f'./办公自动化/files/{name}'
# print(path)
tmp_wb = load_workbook(path)
tmp_sh = tmp_wb.active
sh = wb.create_sheet(name[:-5])
for r in range(1, tmp_sh.max_row + 1):
row_value = []
for c in range(1, tmp_sh.max_column + 1):
value = tmp_sh.cell(r, c).value
row_value.append(value)
sh.append(row_value)
del wb['Sheet']
wb.save('./办公自动化/files/数据合并.xlsx')
if __name__ == '__main__':
copy_data()