Skip to content

Commit

Permalink
Fix: Issue qax-os#1936 CalcCellValue silently fails when formula is =…
Browse files Browse the repository at this point in the history
…OTHER_CELL and OTHER_CELL has a formula evaluation error bug
  • Loading branch information
abdelaziz-ouhammou committed Jul 22, 2024
1 parent d81b4c8 commit dd5c57a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion calc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,10 @@ func (f *File) cellResolver(ctx *calcContext, sheet, cell string) (formulaArg, e
if ctx.iterations[ref] <= f.options.MaxCalcIterations {
ctx.iterations[ref]++
ctx.mu.Unlock()
arg, _ = f.calcCellValue(ctx, sheet, cell)
arg, err = f.calcCellValue(ctx, sheet, cell)
if err != nil && err.Error() != "#N/A" {
return arg, err
}
ctx.iterationsCache[ref] = arg
return arg, nil
}
Expand Down
11 changes: 11 additions & 0 deletions cell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1126,3 +1126,14 @@ func TestSharedStringsError(t *testing.T) {
func TestSIString(t *testing.T) {
assert.Empty(t, xlsxSI{}.String())
}

func TestFormulaRecursionErr(t *testing.T) {
f, err := OpenFile(filepath.Join("test", "FormulaRecursionErr.xlsx"), Options{UnzipXMLSizeLimit: 128})
assert.NoError(t, err)
_, err = f.CalcCellValue("Sheet1", "C1")
assert.Error(t, err)
_, err = f.CalcCellValue("Sheet1", "D1")
assert.Error(t, err)
err = f.Close()
assert.NoError(t, err)
}
Binary file added test/FormulaRecursionErr.xlsx
Binary file not shown.

0 comments on commit dd5c57a

Please sign in to comment.