简体   繁体   English

如何在流光中显示 excel 文件?

[英]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 数据,但为什么它看起来与原始数据不同?

右边是原始的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.使用安装为pip install streamlit-aggridStreamlit AgGrid 组件来显示您的 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.关于颜色,我很确定必须写一些CSS来完成。

Import the module as from st_aggrid import AgGrid , after installing it.安装后,将模块导入为from st_aggrid import AgGrid

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.您可能希望通过AgGrid Doc go了解更多信息,因为它带有一堆您可能感兴趣的特性,关于数据框的样式。

I will recommend you to visit streamlit-aggrid component to have a glance on how the module is implemented in streamlit.我建议您访问streamlit-aggrid 组件,以了解该模块是如何在 streamlit 中实现的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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