利用pandas 和 ttk.Treeviews制作xlsx视图工具
import tkinter as tk from tkinter import ttk import pandas as pd import tkinter.messagebox as msgbox def Start(): msgbox.showinfo('提示', 'OK') fp = pd.read_excel("./test.xlsx") for i in tree.get_children(): tree.delete(i) for _ in range(len(fp.index.values)): tree.insert('','end',value=tuple(fp.iloc[_,[0,1,2]].values)) win = tk.Tk() #win.wm_attributes('-topmost',1) win.geometry("300x1000+10+10") #ttk.Button(win,text="Import it",command=Start).pack() columns = ("A","B","C") tree = ttk.Treeview(win,show="headings",columns=columns,height=45) tree.column("A",width=100,anchor='center') tree.heading("A",text="列A") tree.pack() win.after(500,Start) win.mainloop()
参考:https://blog.csdn.net/weixin_43849588/article/details/104968231