Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tests/samples/invalid_formula.xls
Binary file not shown.
9 changes: 9 additions & 0 deletions tests/test_formulas.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,12 @@ def test_if(self):

def test_choose(self):
self.assertEqual(self.get_value(1, 6), "'C'")

def test_evaluate_name_formula_with_invalid_operand(self):
book = xlrd.open_workbook(from_sample('invalid_formula.xls'))
sheet = book.sheet_by_index(0)
cell = sheet.cell(0, 0)

self.assertEqual(cell.ctype, xlrd.XL_CELL_ERROR)
self.assertIn(cell.value, xlrd.error_text_from_code)

2 changes: 1 addition & 1 deletion xlrd/formula.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ def not_in_name_formula(op_arg, oname_arg):
])
res = Operand(oREF, None, rank, otext)
if bop.kind == oERR or aop.kind == oERR:
res = oERR
res.kind = oERR
elif bop.kind == oREF == aop.kind:
if aop.value is not None and bop.value is not None:
assert len(aop.value) == 1
Expand Down