tkinter,通过 asksaveasfile 使用 openpyxl 保存文件工作簿

tkinter,save file workbook using openpyxl by asksaveasfile

我想使用 tkinter asksaveasfile 对话框创建新的 excel 文件。使用 openpyxl 创建新 excel 文件的众所周知的机制如下。我想将它与 asksaveasfile tkinter 模块一起使用。

from openpyxl import Workbook
foo = Workbook()
foo.active()
foo.save("C:\Users\Dave\Documents\foo.xlxs")

答案是

import openpyxl
from tkinter.filedialog import askdirectory

download_Directory = askdirectory(title="Select Folder Downloading Folder")
scheduler_form = Workbook()
scheduler_form.active
path = download_Directory+"\scheduler_form.xlsx"
scheduler_form.save(path)