writing complex value causes error when opening file with Excel

Issue #418 invalid
created an issue

The following code runs without problems:

import openpyxl

book= openpyxl.Workbook()
sheet= book.active

sheet['A1']= 'int'
sheet['B1']= 'float'
sheet['C1']= 'complex'

sheet['A2']= 5
sheet['B2']= 5.3
sheet['C2']= 5.3+2.J


But, when I attempt to open the file with MS Excel, I get the following error message: "Excel found unreadable content in 'text.xlsx'. Do you want to recover the contents of the workbook?

If I comment out the line that writes the complex number, the file can be opened without problems. So, it would appear that openpyxl is writing the complex value in some way that Excel doesn't like.

Phillip M. Feldman

Comments (4)

  1. CharlieC

    To use complex numbers in Excel you have to use a formula such as COMPLEX(4,5). It is beyond the scope of openpyxl to do this it does not interpret formulae.

  2. Log in to comment