Cannot write cell value using numpy
Created originally on Bitbucket by CoryKramer (Cory Kramer)
The following code works without issue
#!python
import openpyxl
workbook = openpyxl.Workbook()
sheet = workbook.create_sheet('Test')
sheet.cell(row=1, column=1).value = 1.0
However the following version of this code causes an error
#!python
import numpy
import openpyxl
workbook = openpyxl.Workbook()
sheet = workbook.create_sheet('Test')
a = numpy.array([1.0])
sheet.cell(row=1, column=1).value = a[0]
In the latter case, the value
being assigned is of type numpy.float64
. In the Cell._bind_value
method, this type is not considered to be NUMERIC_TYPES
so therefore causes a ValueError
at the end of the method.