Skip to content

Commit dd5c57a

Browse files
Fix: Issue qax-os#1936 CalcCellValue silently fails when formula is =OTHER_CELL and OTHER_CELL has a formula evaluation error bug
1 parent d81b4c8 commit dd5c57a

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

calc.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,10 @@ func (f *File) cellResolver(ctx *calcContext, sheet, cell string) (formulaArg, e
16261626
if ctx.iterations[ref] <= f.options.MaxCalcIterations {
16271627
ctx.iterations[ref]++
16281628
ctx.mu.Unlock()
1629-
arg, _ = f.calcCellValue(ctx, sheet, cell)
1629+
arg, err = f.calcCellValue(ctx, sheet, cell)
1630+
if err != nil && err.Error() != "#N/A" {
1631+
return arg, err
1632+
}
16301633
ctx.iterationsCache[ref] = arg
16311634
return arg, nil
16321635
}

cell_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,3 +1126,14 @@ func TestSharedStringsError(t *testing.T) {
11261126
func TestSIString(t *testing.T) {
11271127
assert.Empty(t, xlsxSI{}.String())
11281128
}
1129+
1130+
func TestFormulaRecursionErr(t *testing.T) {
1131+
f, err := OpenFile(filepath.Join("test", "FormulaRecursionErr.xlsx"), Options{UnzipXMLSizeLimit: 128})
1132+
assert.NoError(t, err)
1133+
_, err = f.CalcCellValue("Sheet1", "C1")
1134+
assert.Error(t, err)
1135+
_, err = f.CalcCellValue("Sheet1", "D1")
1136+
assert.Error(t, err)
1137+
err = f.Close()
1138+
assert.NoError(t, err)
1139+
}

test/FormulaRecursionErr.xlsx

5.41 KB
Binary file not shown.

0 commit comments

Comments
 (0)