自己写的另存为Excel文件的函数,测试可用 def savebook():
wb = op.Workbook()
ws=wb.active
ws.title='新工作簿'
ws.append(titles)
for itm in tree.get_children():
ws.append(tree.item(itm)['values'])
filename = tk.filedialog.asksaveasfilename(filetypes=[('xlsx', '*.xlsx')], initialdir='D:\\')
filename = filename + '.xlsx'
wb.save(filename)