Skip to content

Commit f3521c8

Browse files
authored
Merge pull request #380 from sanshi42/master
bugfix: Fix an occasional compatibility issue when using Excel formulas
2 parents 0c4e80b + 99270dd commit f3521c8

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

tests/samples/invalid_formula.xls

42 KB
Binary file not shown.

tests/test_formulas.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,12 @@ def test_if(self):
7979

8080
def test_choose(self):
8181
self.assertEqual(self.get_value(1, 6), "'C'")
82+
83+
def test_evaluate_name_formula_with_invalid_operand(self):
84+
book = xlrd.open_workbook(from_sample('invalid_formula.xls'))
85+
sheet = book.sheet_by_index(0)
86+
cell = sheet.cell(0, 0)
87+
88+
self.assertEqual(cell.ctype, xlrd.XL_CELL_ERROR)
89+
self.assertIn(cell.value, xlrd.error_text_from_code)
90+

xlrd/formula.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ def not_in_name_formula(op_arg, oname_arg):
953953
])
954954
res = Operand(oREF, None, rank, otext)
955955
if bop.kind == oERR or aop.kind == oERR:
956-
res = oERR
956+
res.kind = oERR
957957
elif bop.kind == oREF == aop.kind:
958958
if aop.value is not None and bop.value is not None:
959959
assert len(aop.value) == 1

0 commit comments

Comments
 (0)