-3

My need is to create a new Excel Workbook in Python (3.6), insert data and leave this Workbook OPEN in Excel for the user to work with.

I'm using openpyxl, but unfortunately, there's no workbook method to open the Workbook in Excel.

I tried saving the Workbook in Windows' TEMP folder and then shell out to open this file using os.system(tempExcelFile) and it does open the file, but my Python program is waiting for this process to terminate and even then hangs.

What solutions can you suggest to accomplish this simple task: create an Excel Workbook, open it in Excel on the Windows machine, and have the Python program continue without waiting for any signal coming back from Excel.

Thanks!

marc_s
  • 675,133
  • 158
  • 1,253
  • 1,388
Mor Sagmon
  • 555
  • 1
  • 10
  • 27

1 Answers1

0

Here's the solution I found working eventually:

excelFile = tempfile.gettempdir() + "\\" + "Employees.xlsx"
wkb.save(excelFile)
subprocess.Popen(excelFile, shell=True)

I'm storing the Excel file in Windows Temp folder, and opening it there. Excel remains open for the user with the file to work with, and the Python program completes asynchronously (the UI remains for the user to call for other operations on the data).

Mor Sagmon
  • 555
  • 1
  • 10
  • 27