简体   繁体   中英

How to display excel file in streamlit?

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

右边是原始的excel文件,左边是streamlit的excel文件

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM