Hey everyone, I’m fairly new to dash and only have a week on top of that in python experience. I’m looking to design an app similar to the vanguard layout, but with a few dynamic fields. I managed to get a live API link from WSJ/FTC to refresh on the first page and format properly. However, I am having a bit of trouble with the second page (similar format to the vanguard example) I have a code that reads the names of a sheet and stores them. I would like to be able to display the contents of the excel sheet in the dash app from the user selection. The code for the excel thing is below -
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import dash_table_experiments as dt
sheet_to_df_map = pd.ExcelFile(‘2013 Onwards Database.xlsm’)
dropdown_options = pd.read_excel(‘2013 Onwards Database.xlsm’, sheet_name=None)
app = dash.Dash()
app.layout = html.Div([
html.H2(“Select Sheet Number”),
html.Div([dcc.Dropdown(id=“field_dropdown”, options=[{
‘label’: i,
‘value’: i
} for i in dropdown_options],
value=‘Sheet3’)],
style={‘width’: ‘25%’,
‘display’: ‘inline-block’}),
dt.DataTable(rows=[{}],
row_selectable=True,
filterable=True,
sortable=True,
selected_row_indices=[],
id=‘datatable’)
])
@app.callback(
dash.dependencies.Output(‘datatable’, ‘rows’),
[dash.dependencies.Input(‘field_dropdown’, ‘value’)])
def update_datatable(user_selection):
if user_selection == ‘Sheet1’:
return sheet_to_df_map.parse(0).to_dict(‘records’)
elif user_selection == ‘Sheet2’:
return sheet_to_df_map.parse(1).to_dict(‘records’)
else:
return sheet_to_df_map.parse(2).to_dict(‘records’)
if name == ‘main’:
app.run_server()
How would I add to this to say, page two of the vanguard app?