In app.py Exports fuer CSV und XLSX hinzugefuegt

This commit is contained in:
2026-06-22 16:04:57 +02:00
parent 00a9b9ebdc
commit 08f64765b5
3 changed files with 31 additions and 4 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ WORKDIR /app
# Erfordert keine schweren Systempakete, das beschleunigt auch den Build!
# Wir installieren direkt die benötigten Python-Bibliotheken
RUN pip3 install --no-cache-dir streamlit pandas plotly
RUN pip3 install --no-cache-dir streamlit pandas plotly openpyxl
# Port für Streamlit öffnen
EXPOSE 8501
+27
View File
@@ -2,6 +2,7 @@ import streamlit as st
import pandas as pd
import plotly.express as px
import numpy as np
import io
# --- Konstanten ---
TB2B = 1024**4 # TB in Bytes
@@ -89,6 +90,32 @@ if auswahl == "Übersicht & Metriken":
})
)
# --- Export-Buttons ---
export_col1, export_col2 = col2.columns(2)
# CSV Export
csv_data = df_department_overview.to_csv(index=True).encode('utf-8')
export_col1.download_button(
label="Export als CSV",
data=csv_data,
file_name="department_overview.csv",
mime="text/csv",
)
# Excel Export
excel_buffer = io.BytesIO()
with pd.ExcelWriter(excel_buffer, engine='openpyxl') as writer:
df_department_overview.to_excel(writer, index=True, sheet_name='Department Overview')
excel_data = excel_buffer.getvalue()
export_col2.download_button(
label="Export als XLSX",
data=excel_data,
file_name="department_overview.xlsx",
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
)
if "department" in df:
fig = px.pie(
df,