Download Button

I have an excel file with multiple sheets and I want to add that excel file in the download button. I don’t know how to do that. I will be very grateful if anyone help me.

Hi, download excel, you can do like this:

with open("example.xlsx", "rb") as file:
    btn = st.download_button(
        label="click me to download excel",
        data=file,
        file_name="new.xlsx",
        mime="application/octet-stream"
        )
1 Like

It gave me an error “AttributeError: module ‘streamlit’ has no attribute 'download_button”.
Sorry for the late reply.

Have you upgrade your streamlit version? This feature only can be used in newer version.
use the comand line to use latest version and restart your app.

pip install streamlit --upgrade
1 Like

It worked. Thanks a lot.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.