python写gui版的excel
时间: 2023-08-26 18:06:30 浏览: 123
你可以使用Python的Tkinter库来编写GUI版的Excel。下面是一个简单的示例代码,可以帮助你开始编写GUI版的Excel:
```python
import tkinter as tk
import pandas as pd
def merge_excel():
base = 'C:\\Users\\11578\\Desktop\\05'
desktop = os.path.join(os.path.expanduser("~"), 'Desktop')
allLineData = pd.DataFrame()
for excelFile in findAllFile(base):
oneFileData = pd.read_excel(excelFile)
allLineData = allLineData.append(oneFileData, ignore_index=True)
writer = pd.ExcelWriter(os.path.join(desktop, '合并后的文件.xls'))
allLineData.to_excel(writer, index=False)
writer.save()
def findAllFile(base):
for root, ds, fs in os.walk(base):
for f in fs:
if f.endswith('.xls') or f.endswith('.xlsx'):
fullname = os.path.join(root, f)
yield fullname
# 创建GUI窗口
window = tk.Tk()
window.title("Excel合并工具")
# 创建按钮
button = tk.Button(window, text="合并Excel", command=merge_excel)
button.pack()
# 运行窗口主循环
window.mainloop()
```
你可以根据自己的需求进行修改和扩展。同时,你可以参考\[2\]中提供的GUI和pandas的参考链接来进一步完善你的程序。
#### 引用[.reference_title]
- *1* *2* [python 读取多个excel整合成一个新的excel(有gui版本)](https://blog.csdn.net/HuangJiaxinZ/article/details/121672584)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文