Prevent re-run of app when user inputs new values into editable grid

Hi everyone,

I am building an app where there is an editable grid where the user can enter volumes. This editable grid is connected to an Excel file, so when the user enters a new value into the grid, it writes back to the Excel file. Also, these values entered for volumes are part of a calculation that computes net sales based on those volumes.

The issue I am having is that every time that the user inputs a value (which then overwrites the Excel file), it causes the app to re-run. I would like for the user’s input to overwrite the Excel file but not to re-run the app.

The app should only be re-run once the user hits the re-load button, which is a button that has the command to re-run the app.

This is the piece of script that displays the excel file in the editable grid and writes back to the file when the user inputs (and the variable “Vol_Cust1” is a script that reads in the excel file via a pd.read_excel command from the same location as the one it is writing back to):

if Customer_selection == ‘Customer 1:
edited_data = st.data_editor(Vol_Cust1,disabled=(Columns_locked),hide_index=True, use_container_width=True)
if edited_data is not None:
edited_data.to_excel(r’C:\Users\cenigk\Desktop\Forecasting app\Inputs\Volume Input\Customer 1.xlsx’, ‘Volumes Input’, index=False)

And then, this is the script for the app re-run function:

if st.button(“Reload page”):
st.experimental_rerun()

(in my version of streamlit, the function that works is still experimental_rerun)

So, can the above code be tweaked so that it does write back to the Excel file but without an app re-run?

KR

Christoffer