├── Helper_Notebook.ipynb ├── README.md ├── Survey_Results.xlsx ├── app.py ├── images ├── credit.txt └── survey.jpg └── requirements.txt /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Turn Your Excel File Into A Web App With Python 3 | 4 | In this tutorial, I am going to show you how to convert Excel Files into a Web Application by using the Python Library Streamlit. The beauty of Streamlit is that you can create web applications directly in Python, without needing to know HTML, CSS, or JavaScript. The Web App is fully interactive and will be updated, whenever you make changes in the Excel file. 5 | 6 | ## Live Demo 7 | 👉 https://surveyresults.pythonandvba.com 8 | 9 | ## Video 10 | 11 | [![YouTube Video](https://img.youtube.com/vi/7zeAIEPJaoQ/0.jpg)](https://youtu.be/7zeAIEPJaoQ) 12 | 13 | 14 | 15 | ## 🤓 Check Out My Excel Add-ins 16 | I've developed some handy Excel add-ins that you might find useful: 17 | 18 | - 📊 **[Dashboard Add-in](https://pythonandvba.com/grafly)**: Easily create interactive and visually appealing dashboards. 19 | - 🎨 **[Cartoon Charts Add-In](https://pythonandvba.com/cuteplots)**: Create engaging and fun cartoon-style charts. 20 | - 🤪 **[Emoji Add-in](https://pythonandvba.com/emojify)**: Add a touch of fun to your spreadsheets with emojis. 21 | - 🛠️ **[MyToolBelt Add-in](https://pythonandvba.com/mytoolbelt)**: A versatile toolbelt for Excel, featuring: 22 | - Creation of Pandas DataFrames and Jupyter Notebooks from Excel ranges 23 | - ChatGPT integration for advanced data analysis 24 | - And much more! 25 | 26 | 27 | 28 | ## 🤝 Connect with Me 29 | - 📺 **YouTube:** [CodingIsFun](https://youtube.com/c/CodingIsFun) 30 | - 🌐 **Website:** [PythonAndVBA](https://pythonandvba.com) 31 | - 💬 **Discord:** [Join the Community](https://pythonandvba.com/discord) 32 | - 💼 **LinkedIn:** [Sven Bosau](https://www.linkedin.com/in/sven-bosau/) 33 | - 📸 **Instagram:** [sven_bosau](https://www.instagram.com/sven_bosau/) 34 | 35 | ## ☕ Support 36 | If you appreciate the project and wish to encourage its continued development, consider [supporting my work](https://pythonandvba.com/coffee-donation). 37 | [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://pythonandvba.com/coffee-donation) 38 | 39 | ## Feedback & Collaboration 40 | For feedback, suggestions, or potential collaboration opportunities, reach out at contact@pythonandvba.com. 41 | ![Logo](https://www.pythonandvba.com/banner-img) 42 | -------------------------------------------------------------------------------- /Survey_Results.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sven-Bo/excel-webapp-streamlit/0d71eec4b95cd742e3ec2c7106572935fdfcb61b/Survey_Results.xlsx -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import streamlit as st 3 | import plotly.express as px 4 | from PIL import Image 5 | 6 | st.set_page_config(page_title='Survey Results') 7 | st.header('Survey Results 2021') 8 | st.subheader('Was the tutorial helpful?') 9 | 10 | ### --- LOAD DATAFRAME 11 | excel_file = 'Survey_Results.xlsx' 12 | sheet_name = 'DATA' 13 | 14 | df = pd.read_excel(excel_file, 15 | sheet_name=sheet_name, 16 | usecols='B:D', 17 | header=3) 18 | 19 | df_participants = pd.read_excel(excel_file, 20 | sheet_name= sheet_name, 21 | usecols='F:G', 22 | header=3) 23 | df_participants.dropna(inplace=True) 24 | 25 | # --- STREAMLIT SELECTION 26 | department = df['Department'].unique().tolist() 27 | ages = df['Age'].unique().tolist() 28 | 29 | age_selection = st.slider('Age:', 30 | min_value= min(ages), 31 | max_value= max(ages), 32 | value=(min(ages),max(ages))) 33 | 34 | department_selection = st.multiselect('Department:', 35 | department, 36 | default=department) 37 | 38 | # --- FILTER DATAFRAME BASED ON SELECTION 39 | mask = (df['Age'].between(*age_selection)) & (df['Department'].isin(department_selection)) 40 | number_of_result = df[mask].shape[0] 41 | st.markdown(f'*Available Results: {number_of_result}*') 42 | 43 | # --- GROUP DATAFRAME AFTER SELECTION 44 | df_grouped = df[mask].groupby(by=['Rating']).count()[['Age']] 45 | df_grouped = df_grouped.rename(columns={'Age': 'Votes'}) 46 | df_grouped = df_grouped.reset_index() 47 | 48 | # --- PLOT BAR CHART 49 | bar_chart = px.bar(df_grouped, 50 | x='Rating', 51 | y='Votes', 52 | text='Votes', 53 | color_discrete_sequence = ['#F63366']*len(df_grouped), 54 | template= 'plotly_white') 55 | st.plotly_chart(bar_chart) 56 | 57 | # --- DISPLAY IMAGE & DATAFRAME 58 | col1, col2 = st.columns(2) 59 | image = Image.open('images/survey.jpg') 60 | col1.image(image, 61 | caption='Designed by slidesgo / Freepik', 62 | use_column_width=True) 63 | col2.dataframe(df[mask]) 64 | 65 | # --- PLOT PIE CHART 66 | pie_chart = px.pie(df_participants, 67 | title='Total No. of Participants', 68 | values='Participants', 69 | names='Departments') 70 | 71 | st.plotly_chart(pie_chart) 72 | -------------------------------------------------------------------------------- /images/credit.txt: -------------------------------------------------------------------------------- 1 | Designed by slidesgo / Freepik -------------------------------------------------------------------------------- /images/survey.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sven-Bo/excel-webapp-streamlit/0d71eec4b95cd742e3ec2c7106572935fdfcb61b/images/survey.jpg -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | openpyxl==3.0.10 2 | plotly==4.14.3 3 | pandas==1.4.3 4 | streamlit==1.12.0 5 | Pillow==9.2.0 6 | --------------------------------------------------------------------------------