This commit is contained in:
2026-02-01 07:18:20 +01:00
parent 7b0404bfe3
commit 3d11661997
7 changed files with 1074 additions and 116 deletions

View File

@@ -61,17 +61,28 @@ def get_data():
# ==============================
def auto_adjust_columns(writer, df, sheet_name):
"""Pomocná funkce pro automatické rozšíření sloupců v Excelu"""
"""Bezpečné automatické nastavení šířky sloupců"""
worksheet = writer.sheets[sheet_name]
for idx, col in enumerate(df.columns):
max_len = max(
df[col].astype(str).map(len).max(),
len(str(col))
) + 2
if max_len > 60: max_len = 60
series = df[col]
max_len = len(str(col)) # minimálně délka hlavičky
for val in series:
if val is None or (isinstance(val, float) and pd.isna(val)):
length = 0
else:
length = len(str(val))
if length > max_len:
max_len = length
max_len = min(max_len + 2, 60)
worksheet.set_column(idx, idx, max_len)
# ==============================
# 🚀 HLAVNÍ LOGIKA
# ==============================