diff --git a/cell/model/Workbook.js b/cell/model/Workbook.js index 57bd5854c8..2b1796b46c 100644 --- a/cell/model/Workbook.js +++ b/cell/model/Workbook.js @@ -15460,11 +15460,14 @@ const aExcludeFormulas = AscCommonExcel.aExcludeRecursiveFormulas; const oCycleCells = new Map(); - _foreachRefElements(function (oElem, nIndex) { + _foreachRefElements(function (oElem, nIndex, nLastIndex) { if (oElem.containCell2(oListenerCell)) { const nIndexWithFunction = nIndex + 2; + if (nIndexWithFunction > nLastIndex) { + return; + } const oElemWithFunction = aOutStack[nIndexWithFunction]; - if (oElemWithFunction.type === cElementType.func && aExcludeFormulas.includes(oElemWithFunction.name)) { + if (oElemWithFunction && oElemWithFunction.type === cElementType.func && aExcludeFormulas.includes(oElemWithFunction.name)) { oCycleCells.set(true, nIndex); return; }