[HandBrake_recursive] export_xlsx sans écraser le fichier existant

This commit is contained in:
lionel 2025-05-15 22:46:23 +02:00
parent dbb3cc68a1
commit efa7127914

View File

@ -9,13 +9,15 @@ import math
import json
import argparse
import ffmpeg
from datetime import datetime
import pydbus as dbus
import openpyxl
from openpyxl.styles import PatternFill
from openpyxl.formatting.rule import CellIsRule
date = datetime.now().strftime("%Y-%m-%d_%Hh%M")
def inhibit_arret(application, raison):
inhibiteurs = {}
@ -95,10 +97,17 @@ def set_column_width(ws, column_range, width=15):
ws.column_dimensions[col].width = width
def export_xlsx(lignes, fichier_sortie="résumé.xlsx"):
# Créer un nouveau classeur et sélectionner la feuille active
wb = openpyxl.Workbook()
ws = wb.active
ws.title = "Résumé"
# Charger le classeur existant ou en créer un nouveau
if os.path.exists(fichier_sortie):
wb = openpyxl.load_workbook(fichier_sortie)
else:
wb = openpyxl.Workbook()
# Supprimer la feuille par défaut si on ajoute une nouvelle
default_sheet = wb.active
wb.remove(default_sheet)
# Créer une nouvelle feuille
ws = wb.create_sheet(title=date)
# En-têtes
headers = ["Fichier", "Codec", "Résolution", "Action", "Durée", "Taille SRC", "Bitrate SRC",