u/schmidtbag

Most basic openpyxl example still results in Excel throwing an error

I've been trying to use openpyxl to create an automated report. Whenever Excel opens the file, it gives a uselessly vague error saying it removed "unreadable content", even though when saving the file it actually increases in size.

Turns out though that even the most basic code doesn't work. The following will produce the same error in Excel:

from openpyxl import Workbook
wb = Workbook()
ws = wb.active
ws.title = "Sheet"
ws["A1"] = "Header"
ws["A2"] = "Some Data"
wb.save("simple_example.xlsx")

What else can I do here? Unfortunately, the actual report is run daily and is for customers to view, so I can't just say "oh just ignore it, the report is fine".

reddit.com
u/schmidtbag — 1 day ago