How to display excel file in streamlit?

Question:

I’m trying to display the complete excel data in streamlit but why does it look different from the original?

the right side is the original excel file and on the left side is the excel file that is in streamlit

from streamlit_option_menu import option_menu
import pandas as pd

# 1. as sidebar menu
with st.sidebar:
    selected = option_menu("Product", ["BFR CORPORATE", 'BFR mikro', 'BFR Consumer', 'BRF'], 
        icons=['play', 'play'], menu_icon="cast", default_index=1)
    selected
    print(selected)
df = pd.read_excel("contoh.xlsx")
st.dataframe(df)
Asked By: Fatih Hurisqi

||

Answers:

Use Streamlit AgGrid Component which is installed as pip install streamlit-aggrid to display your dataframe. That might handle the problem you are facing.

With regards to the colour, I am pretty sure will have to write some CSS to acomplish that.

Import the module as from st_aggrid import AgGrid, after installing it.

from st_aggrid import AgGrid

AgGrid(df)

You might want to go through the AgGrid Doc for more information because it comes with a bunch of features which you might be interested, with regards to the styling of dataframes.

I will recommend you to visit streamlit-aggrid component to have a glance on how the module is implemented in streamlit.

Answered By: Jamiu S.
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.