| | |
| | | import random |
| | | import shutil |
| | | import string |
| | | from datetime import datetime |
| | | import threading |
| | | import time |
| | | |
| | | from datetime import datetime |
| | | from openpyxl import load_workbook |
| | | from Log import logger |
| | | |
| | | |
| | | def clear_blank_rows(sheet): |
| | |
| | | source_sheet.cell(row=row, column=col).value for col in range(4, source_sheet.max_column + 1)): |
| | | target_sheet.append( |
| | | [source_sheet.cell(row=row, column=col).value for col in range(1, source_sheet.max_column + 1)]) |
| | | |
| | | |
| | | def delete_file_after_delay(file_path, delay_minutes): |
| | | delay_seconds = delay_minutes * 60 |
| | | |
| | | def delete_file(): |
| | | time.sleep(delay_seconds) |
| | | try: |
| | | if os.path.exists(file_path): |
| | | os.remove(file_path) |
| | | except Exception as e: |
| | | logger.error(f"定时删除Excel文件时发生错误: {e}") |
| | | |
| | | threading.Thread(target=delete_file).start() |
| | | |
| | | |
| | | def run_conformity(file_path, print_path): |
| | |
| | | template_excel.save(output_path) |
| | | template_excel.close() |
| | | |
| | | # 合并完成后删除无用文件 |
| | | delete_file_after_delay(output_path, 5) |
| | | |
| | | try: |
| | | for filename in os.listdir(file_path): |
| | | file_path_full = os.path.join(file_path, filename) |
| | | try: |
| | | if os.path.isfile(file_path_full) or os.path.islink(file_path_full): |
| | | os.unlink(file_path_full) |
| | | elif os.path.isdir(file_path_full): |