Skip to content

Commit

Permalink
Add address returning methods to FsCellsCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
omaus committed Mar 18, 2023
1 parent 6cf942d commit a97d858
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/FsSpreadsheet/Cells/FsCellsCollection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -590,4 +590,29 @@ type FsCellsCollection() =

/// Returns all FsCells in an FsCellsCollection with the given rowIndex.
static member getCellsInRow rowIndex (cellsCollection : FsCellsCollection) =
cellsCollection.GetCellsInRow rowIndex
cellsCollection.GetCellsInRow rowIndex

/// <summary>Returns the upper left corner of the FsCellsCollection.</summary>
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 -> failwith "The FsCellsCollection is empty."

/// <summary>Returns the upper left corner of a given FsCellsCollection.</summary>
static member getFirstAddress (cells : FsCellsCollection) =
cells.GetFirstAddress()

/// <summary>Returns the lower right corner of the FsCellsCollection.</summary>
member this.GetLastAddress() =
FsAddress(this.MaxRowNumber, this.MaxColumnNumber)

/// <summary>Returns the lower right corner of a given FsCellsCollection.</summary>
static member getLastAddress (cells : FsCellsCollection) =
cells.GetLastAddress()

// TO DO: Add method to get FsRange when possible

0 comments on commit a97d858

Please sign in to comment.