@@ -609,13 +609,13 @@ export class NumericAggregationPlugin extends FunctionPlugin implements Function
609609 /**
610610 * Performs range operation on given range
611611 *
612- * @param ast - cell range ast
613- * @param state
614- * @param initialAccValue - initial accumulator value for reducing function
615- * @param functionName - function name to use as cache key
616- * @param reducingFunction - reducing function
617- * @param mapFunction
618- * @param coercionFunction
612+ * @param { CellRangeAst | ColumnRangeAst | RowRangeAst } ast - cell range ast
613+ * @param { InterpreterState } state - interpreter state
614+ * @param { T } initialAccValue - initial accumulator value for reducing function
615+ * @param { string } functionName - function name to use as cache key
616+ * @param { BinaryOperation<T> } reducingFunction - reducing function
617+ * @param { MapOperation<T> } mapFunction - mapper transforming coerced scalar
618+ * @param { coercionOperation } coercionFunction - scalar-to-number coercer
619619 */
620620 private evaluateRange < T > ( ast : CellRangeAst | ColumnRangeAst | RowRangeAst , state : InterpreterState , initialAccValue : T , functionName : string , reducingFunction : BinaryOperation < T > , mapFunction : MapOperation < T > , coercionFunction : coercionOperation ) : T | CellError {
621621 let range
@@ -629,7 +629,7 @@ export class NumericAggregationPlugin extends FunctionPlugin implements Function
629629 }
630630 }
631631
632- if ( ! this . dependencyGraph . sheetMapping . hasSheetWithId ( range . start . sheet , { includePlaceholders : false } ) || ! this . dependencyGraph . sheetMapping . hasSheetWithId ( range . end . sheet , { includePlaceholders : false } ) ) {
632+ if ( ! this . isSheetValid ( range ) ) {
633633 return new CellError ( ErrorType . REF , ErrorMessage . SheetRef )
634634 }
635635
@@ -657,6 +657,16 @@ export class NumericAggregationPlugin extends FunctionPlugin implements Function
657657 return value
658658 }
659659
660+ /**
661+ * Checks whether both ends of a range point to existing sheets (placeholders excluded).
662+ */
663+ private isSheetValid ( range : AbsoluteCellRange ) : boolean {
664+ return (
665+ this . dependencyGraph . sheetMapping . hasSheetWithId ( range . start . sheet , { includePlaceholders : false } ) &&
666+ this . dependencyGraph . sheetMapping . hasSheetWithId ( range . end . sheet , { includePlaceholders : false } )
667+ )
668+ }
669+
660670 /**
661671 * Returns list of values for given range and function name
662672 *
0 commit comments