St.download button not working with .xlsx created with openpyxl

I finally figured this out if it helps anyone else … you can’t just read it as a filestream. You have to read it as a bytesstream and then specify the mime type:

with open("./outputs/summary.xlsx", "rb") as file:
  btn = st.download_button(
    label="Download",
    data=file,
    file_name="text_rb2.xlsx",
    mime="application/vnd.ms-excel"
  )