1、使用库函数shutil.copyfile
2、参考【Python】openpyxl 复制带格式的Excel 表格_openpyxl复制单元格格式_是小菜欸的博客-CSDN博客
def copy_excel_content(srcfile,dstfile):
wb = openpyxl.load_workbook(srcfile)
wb2 = openpyxl.Workbook()
sheetnames = wb.sheetnames
for sheetname in sheetnames:
#print(sheetname)
sheet = wb[sheetname]
sheet2 = wb2.create_sheet(sheetname)
# tab颜色
sheet2.sheet_properties.tabColor = sheet.sheet_properties.tabColor
# 开始处理合并单元格形式为“(<CellRange A1:A4>,),替换掉(<CellRange 和 >,)' 找到合并单元格
wm = list(sheet.merged_cells)
if len(wm) > 0:
for i in range(0, len(wm)):
cell2 = str(wm[i]).replace(