diff --git a/src/FsSpreadsheet/Cells/FsCellsCollection.fs b/src/FsSpreadsheet/Cells/FsCellsCollection.fs index 462016b7..fee602dc 100644 --- a/src/FsSpreadsheet/Cells/FsCellsCollection.fs +++ b/src/FsSpreadsheet/Cells/FsCellsCollection.fs @@ -694,14 +694,12 @@ type FsCellsCollection() = /// Returns the upper left corner of the FsCellsCollection. /// member this.GetFirstAddress() = - try - let minRow = _rowsCollection.Keys |> Seq.min - let minCol = - _rowsCollection.Values - |> Seq.minBy (fun d -> Seq.min d.Keys) - |> fun d -> Seq.min d.Keys - FsAddress(minRow, minCol) - with :? System.ArgumentException -> FsAddress(0, 0) + let minRow = _rowsCollection.Keys |> Seq.min + let minCol = + _rowsCollection.Values + |> Seq.minBy (fun d -> Seq.min d.Keys) + |> fun d -> Seq.min d.Keys + FsAddress(minRow, minCol) /// /// Returns the upper left corner of a given FsCellsCollection. diff --git a/src/FsSpreadsheet/FsWorksheet.fs b/src/FsSpreadsheet/FsWorksheet.fs index dbd83887..1665c6d8 100644 --- a/src/FsSpreadsheet/FsWorksheet.fs +++ b/src/FsSpreadsheet/FsWorksheet.fs @@ -286,10 +286,9 @@ type FsWorksheet (name, fsRows, fsTables, fsCellsCollection) = /// Returns the highest index of any FsRow. /// member self.GetMaxRowIndex() = - try - self.Rows - |> List.maxBy (fun r -> r.Index) - with :? System.ArgumentException -> failwith "The FsWorksheet has no FsRows." + if self.Rows.IsEmpty then failwith "The FsWorksheet has no FsRows." + self.Rows + |> List.maxBy (fun r -> r.Index) /// /// Returns the highest index of any FsRow in a given FsWorksheet.