I have a pandas dataframe which is generated by my code… I’m trying to convert it into excel file and then allow user to download the excel file… but when i’m clicking on the button, exact same button is appearing right below that button and download is starting only when i’m clicking on that second download button.
# Save output file to BytesIO object output_buffer = BytesIO() with pd.ExcelWriter(output_buffer) as writer: output_df.to_excel(writer, index=False) # Add download button if st.button("Download Output"): output_buffer.seek(0) st.download_button( label="Download Output", data=output_buffer, file_name="output.xlsx", mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" )
If I click on the download button, it should start the download immediately
two download button are appearing when i click on the download button. and download starts after clicking on the second download button.
- Streamlit version: latest
- Python version: latest