NPV function fails when passed range of cashflows
Closed this issue · 1 comments
Twoy519 commented
What actually happened
I have an excel file (call it "test.xlsx") with the following layout:
Sheet1!A1 -> =NPV(0.1,B1:C1)
Sheet1!B1 -> 10
Sheet1!C1 -> 20
I am attempting to evaluate cell Sheet1!A1 with the following code in test.py
from pycel import ExcelCompiler
excel = ExcelCompiler(filename="test.xlsx")
print("A1 is %s" % excel.evaluate('Sheet1!A1'))
excel.set_value('Sheet1!B1', 200)
print('A1 is now %s' % excel.evaluate('Sheet1!A1'))
This produces a value error I believe caused by passing a range instead of a comma-separated list of cells:
env ❯ python test.py
A1 is 25.6198347107438
A1 is now #VALUE!
What was expected to happen
I would expect this to evaluate A1 to 198.347 and produce the following console log:
env ❯ python test.py
A1 is 25.6198347107438
A1 is now 198.3471074380165
If I change the formula in cell A1 to =NPV(0.1, B1,C1)
this does evaluate correctly
Environment
env ❯ pip freeze --local
decorator==4.4.1
et-xmlfile==1.0.1
jdcal==1.4.1
networkx==2.4
numpy==1.18.1
openpyxl==3.0.3
pycel==1.0b22
python-dateutil==2.8.1
ruamel.yaml==0.16.10
ruamel.yaml.clib==0.2.0
six==1.14.0
env ❯ python -V
Python 3.7.5
>>> import platform
>>> platform.platform()
Darwin-19.3.0-x86_64-i386-64bit'