How can I use tkinter to prompt users to save a DataFrame to an Excel file?
design an example of how the process would be, but you must take into account the libraries used to generate the Excel file, then adapt it to your needs, taking into account that you have been slow to answer this question. I invite you to investigate the libraries used and They want to create their file with colors, fonts and formulas in a personalized way.
import xlwtfrom xlwt import Workbookimport easygui as egfrom tkinter import *from tkinter import ttkimport tkinter as tkdef generator(): documento=Workbook() insert_celdas = documento.add_sheet('Nomina') cambio=insert_celdas.set_portrait(False) extension =["*.xls"] gplanilla=eg.filesavebox(msg="save file", title="",default='file_name_default', filetypes=extension) if (gplanilla is not None) and (len(gplanilla)!=0): documento.save(str(gplanilla)+".xls") print("Proceso de generacion de nomina completado") else: print("cancelado proceso de generacion de nomina") return Falsewindow=Tk()window.geometry("508x400+0+0")window.title("my code (the saltorman)")Button(window,text="generate file excel",command=generator).pack()window.mainloop()
There shouldn't be mode
option. This is enough:
savefile = asksaveasfilename(filetypes=(("Excel files", "*.xlsx"), ("All files", "*.*") ))