1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| import openpyxl
print("注意:"+"\n" "1、此程序只支持XLSX格式文件;"+"\n" "2、程序运行前需调整好打印预览模式;"+"\n" "3、程序不会复制图片,运行完成后需手动复制图片。"+"\n")
wb_name = input("请输入文件名称:") wb = openpyxl.load_workbook(f'{wb_name}.xlsx') old_sheet = wb.worksheets[0] sheet_name = old_sheet.title
num = int(input("请输入需要复制的数量:"))
for i in range(2,num+1): new_sheet = wb.copy_worksheet(old_sheet) new_sheet.title = sheet_name + str(i)
print("已生成"f'{num}'"个sheet") wb.save(f'{wb_name}.xlsx')
|