Stefan Tončev
Stefan Tončev

Reputation: 3

Excel file can't be opened after saved from Tkinter

I am using xlsxwriter library to write data in excel file and it works fine, when excel file is saved in root directory.

I want to enable user to choose where to save the file, so I am using from asksaveasfile from tkinter.filedialog :

files = [('Excel Document', '.xlsx'), ('All Files', '*.*')]
workbook = asksaveasfile(filetypes=files, defaultextension=files)

The file saves in specified folder, but won't open:

Excel cannot open the file

I also tried .xls , again, file can't be opened.

Thank you in advance!

Upvotes: 0

Views: 297

Answers (1)

Bijan
Bijan

Reputation: 136

Your code is not complete and can not be fixed if you do not include the saving part (what happens to workbook after user choose file to save?).

It seems you are writing an empty file. Check if it has 0 size or not?

Upvotes: 1

Related Questions