diff --git a/xl-cli/src/com/tjclp/xl/cli/commands/ReadCommands.scala b/xl-cli/src/com/tjclp/xl/cli/commands/ReadCommands.scala index 7267e93..7f81325 100644 --- a/xl-cli/src/com/tjclp/xl/cli/commands/ReadCommands.scala +++ b/xl-cli/src/com/tjclp/xl/cli/commands/ReadCommands.scala @@ -448,7 +448,9 @@ object ReadCommands: ) ) else - val sheet = sheetOpt.getOrElse(wb.sheets.head) + // Safe: wb.sheets.isEmpty is checked above, so headOption is always Some + val sheet = (sheetOpt.orElse(wb.sheets.headOption): @unchecked) match + case Some(s) => s for tempSheet <- applyOverrides(sheet, overrides) diff --git a/xl-evaluator/src/com/tjclp/xl/formula/graph/DependencyGraph.scala b/xl-evaluator/src/com/tjclp/xl/formula/graph/DependencyGraph.scala index 850ee2d..48db1a7 100644 --- a/xl-evaluator/src/com/tjclp/xl/formula/graph/DependencyGraph.scala +++ b/xl-evaluator/src/com/tjclp/xl/formula/graph/DependencyGraph.scala @@ -207,7 +207,10 @@ object DependencyGraph: .toValues(call.args) .exists { case ArgValue.Expr(e) => containsUnqualifiedCellReferences(e) - case ArgValue.Range(_) => true + case ArgValue.Range(loc) => + loc match + case TExpr.RangeLocation.Local(_) => true + case TExpr.RangeLocation.CrossSheet(_, _) => false case ArgValue.Cells(_) => true }