简体   繁体   English

使用 openpyxl python 创建临时文件 excel

[英]Creating a temporary excel file using openpyxl python

I made a program that extracts specific data from an existing excel file.我制作了一个程序,从现有的 excel 文件中提取特定数据。

Now I want that data to be shown in an excel file but I don't want to save it on the system现在我希望该数据显示在 excel 文件中,但我不想将其保存在系统中

该 GUI 的图像

This is the GUI of that application which I am making这是我正在制作的那个应用程序的 GUI

Now I want to remove that Select file save destination Instead of that I want that when the user clicks on the Extract button It opens up an excel window without saving a file and the user can see the extracted data if the user wants they can save it otherwise just close the Excel window without saving it.现在我想删除那个Select 文件保存目的地而不是我想要当用户点击提取按钮时它打开一个 excel window而不保存文件并且用户可以看到提取的数据如果用户想要他们可以保存它否则只需关闭 Excel window 而不保存。

Currently, I am using the Openpyxl module to extract the data from an excel file目前,我正在使用 Openpyxl 模块从 excel 文件中提取数据

What should I do?我应该怎么办?

Currently, I am allowing the user to select a folder to save the file目前,我允许用户到 select 一个文件夹来保存文件

But I want like when we normally open Excel there is a blank sheet we fill data there and then if we want to save it we save otherwise we just close the window.但我想当我们正常打开 Excel 时,有一张空白表,我们在那里填写数据,然后如果我们想保存它,我们就保存,否则我们只关闭 window。

I want the same thing here Instead of saving the file I want to open an excel window with that data and if the user wants to save the file they can save or do whatever they want.我在这里想要同样的东西,而不是保存文件,我想用该数据打开 excel window,如果用户想要保存文件,他们可以保存或做任何他们想做的事情。

Your requirement can be solved using xlwings module of python您的需求可以使用 python 的xlwings模块来解决

you can try below code to open excel:您可以尝试使用以下代码打开 excel:

import xlwings as xw
wb = xw.Book()  # this will open a new workbook

you can find more about xlwings from documentation您可以从文档中找到有关 xlwings 的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM