我创建了一个仪表板,可以读取excel文件并通过python破折号显示内容。但是,问题在于它仅在第一个选项卡中显示数据。我的excel文件有5个标签,我想显示所有标签,也可以将其下载。下面是正在使用的代码。
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
df = pd.read_excel('ReturnsData.xlsx')
def generate_table(dataframe, max_rows=10):
return html.Table(
# Header
[html.Tr([html.Th(col) for col in dataframe.columns])] +
# Body
[html.Tr([
html.Td(dataframe.iloc[i][col]) for col in dataframe.columns
]) for i in range(min(len(dataframe), max_rows))]
)
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H4(children='Return Troubleshooting report'),
generate_table(df)
])
if __name__ == '__main__':
app.run_server(debug=True)
我必须进行哪些更改?