I have two dataframes, which I would like to export to one excel file as different sheets. I am writing this for people who aren't familiar with Python and would like to give them the option to decide where to save the file. So far, I have the below code but I do not know how to edit it so it allows me to save multiple dataframes to different sheets. This only works for one DF at the moment. Any help appreciated!
root= tk.Tk()
canvas1 = tk.Canvas(root, width = 300, height = 300, bg = 'lightsteelblue2', relief = 'raised')
canvas1.pack()
def exportExcel ():
global df
export_file_path = filedialog.asksaveasfilename(defaultextension='.xlsx')
df.to_excel (export_file_path, index = False, header=True)
saveAsButtonExcel = tk.Button(text='Export Excel', command=exportExcel, bg='green', fg='white', font=('helvetica', 12, 'bold'))
canvas1.create_window(150, 150, window=saveAsButtonExcel)
root.mainloop()
I have df1 and df2 I would like to use embed into one excel file...thanks!