The following code will run without exception, but creates an invalid workbook. This is caused because Excel does not appear to have a representation of infinity. The same problem occurs when trying to write a
numpy.inf value. I'm not sure what the correct behavior is here: either raise an exception, or write "inf" as a string.
import openpyxl wb = openpyxl.Workbook() sheet = wb.create_sheet("Test") sheet["A1"] = float("inf") wb.save("test.xlsx")
Tested on openpyxl 2.4.8 and 2.5.0b1, both installed via anaconda/conda-forge.