microsoft / python-in-excel

Python in Microsoft Excel
MIT License
490 stars 31 forks source link

TypeError when adding a python value and excel value #44

Closed cvdstap closed 2 weeks ago

cvdstap commented 9 months ago

The formula is to add 2 integer value's in python : "=PY(xl("C141")+xl("C142")). When you enter the formula the error code TypeError occur, but running a second calculation show the correct value.

Not sure why this happen.

=PY(xl("C141")+xl("C142")) --

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

  | 5 | -- | -- | --   | 7 |   | simple formula : | 12

keyur32 commented 8 months ago

Hi there, I wasn't able to reproduce this. Do you have a screenshot for example?

cvdstap commented 8 months ago

Hi, I have included the Excel-file with the strange behaviour. The cell E7 is once calculated as value 12, the next time I calculate the same cell I get the enclosed error (see picture). TypeError

I hope this helps to understand the issue. TypeErrorxlsx.xlsx

salabim commented 8 months ago

This certainly looks like a bug.

But, it is easy to solve: Just set the Python Output value (accessible with a right mouse click) of D5 and D6 to "Excel Value" instead of "Python Object"

ncalm commented 8 months ago

I was able to reproduce it. @salabim is right, if you want to reliably use a reference in the xl method, you should pass it an Excel value, not a Python object.

Nevertheless, it's not behaving consistently with successive calculations. It cycles between int + int and int + NoneType.

image

keyur32 commented 7 months ago

Update: under investigation. We'll have some changes coming out that may cause this bug to no longer repro as well in the next couple of weeks.

keyur32 commented 2 weeks ago

Closing this out as it no longer repros

image