Python - Converting excel XLSM to XLS using panda and tkinter - also looking to add a background image as well. | SoloLearn: Learn to code for FREE!

+1

Python - Converting excel XLSM to XLS using panda and tkinter - also looking to add a background image as well.

Pretty new to Python so not sure what is going wrong with the below code, I am trying to convert xlsm to xls. The other issue I am facing is that the xlsm files I have contact close to the max of 1,048,576 and.xls only allows 65535 rows so would have to copy over a maximum of 65000 rows just to be save and save this into a xls format. for example output1.xls, output2.xls, output3.xls until all rows have been copied and saved. The reason I am converting to xls is to upload to a database using SSMS. import tkinter as tk from tkinter import filedialog from tkinter import messagebox import pandas as pd from PIL import ImageTk,Image root= tk.Tk() root.iconbitmap("") root.title("Excel Conversion Tool") canvas1 = tk.Canvas(root, width = 300, height = 260, bg = 'lightblue', relief = 'raised') canvas1.pack() label0 = tk.Label(root, text='Errors email: ', bg = 'lightblue') label0.config(font=('helvetica', 10, 'bold')) canvas1.create_window(150, 30, window=label0) def getExcel (): global read_file import_file_path = filedialog.askopenfilename() read_file = pd.read_excel (import_file_path) browseButton_Excel = tk.Button(text=" Import Excel File ", command=getExcel, bg='lightgrey', fg='black', font=('helvetica', 12, 'bold')) canvas1.create_window(150, 80, window=browseButton_Excel) def convertToCSV (): global read_file export_file_path = filedialog.asksaveasfilename(defaultextension='.csv') read_file.to_csv (export_file_path, index = None, header=True) saveAsButton_CSV = tk.Button(text='Convert Excel to CSV', command=convertToCSV, bg='lightgrey', fg='black', font=('helvetica', 12, 'bold')) canvas1.create_window(150, 130, window=saveAsButton_CSV) def convertToXLS (): global read_file export_file_path = filedialog.asksaveasfilename(defaultextension='.xls') read_file.to_XLS (export_file_path, index = None, header=True) save

5/16/2020 9:54:21 AM

Daniel Eldridge

0 Answers

New Answer