Any news about this topic ? Did you managed to create something ?
Not yet, the work around was to create an export button that generate a csv instead of actually copying the dataframe.
Hope it helps:
csv = df_export.to_csv(index=False)
b64 = base64.b64encode(csv.encode()).decode()
# st.markdown('### **⬇️ Download output CSV File **')
href = f'<a class="streamlit-button small-button"
My objective was to export this clipboard to excel, i didn’t find a easy way to use clipboard, instead i’m downloading df as xlsx and use it to copy for my sheets.
I used Heroku to deploy this app, so using href didn’t work, i think something related to VM used… So i used new function st.download_button and it’s works
I managed that with this:
# Function to convert csv to xlsx @st.cache def to_excel(df): output = BytesIO() writer = pd.ExcelWriter(output, engine='xlsxwriter') df.to_excel(writer, sheet_name='Sheet1',index=False) writer.save() processed_data = output.getvalue() return processed_data
This function i get from one topic … And to download it…
df= to_excel(df) st.download_button(label="Download",data=df,file_name='df.xlsx')
See if could be useful for you…
How do I identify and throw a message if the data has been copied using this. For example: Once a person click on the button, Can I throw some kind of message saying dataframe as been copied?
This works well for me (on windows):
import pyperclip # Your code ...# pyperclip.copy(my_dataframe.to_csv())