diff --git a/src/FsSpreadsheet/Cells/FsCellsCollection.fs b/src/FsSpreadsheet/Cells/FsCellsCollection.fs index 3958ecbf..5be81127 100644 --- a/src/FsSpreadsheet/Cells/FsCellsCollection.fs +++ b/src/FsSpreadsheet/Cells/FsCellsCollection.fs @@ -75,7 +75,12 @@ type FsCellsCollection() = | None -> false - /// Empties the whole FsCellsCollection. + /// Creates an FsCellsCollection from the given FsCells. + /// Derives row- and columnIndeces from the FsAddress of the FsCells. + static member createFromCells (cells : seq) = + FsCellsCollection().Add cells + + /// Empties the whole FsCellsCollection. member this.Clear() = _count <- 0; @@ -86,6 +91,8 @@ type FsCellsCollection() = _maxRowUsed <- 0; _maxColumnUsed <- 0 + this + //public void Add(XLSheetPoint sheetPoint, XLCell cell) //{ // Add(sheetPoint.Row, sheetPoint.Column, cell); @@ -118,14 +125,32 @@ type FsCellsCollection() = | None -> () - /// Adds an FsCell of given rowIndex and columnIndex to an FsCellsCollection. - static member add rowIndex colIndex (cell : FsCell) (cellsCollection : FsCellsCollection) = + this + + /// Adds an FsCell of given rowIndex and columnIndex to an FsCellsCollection. + static member addCellWithIndeces rowIndex colIndex (cell : FsCell) (cellsCollection : FsCellsCollection) = cellsCollection.Add(rowIndex, colIndex, cell) /// Adds an FsCell to the FsCellsCollection. /// Derives row- and columnIndex from the FsAddress of the FsCell. - member self.Add(cell : FsCell) = - self.Add(cell.Address.RowNumber, cell.Address.ColumnNumber, cell) + member this.Add(cell : FsCell) = + this.Add(cell.Address.RowNumber, cell.Address.ColumnNumber, cell) + + /// Adds an FsCell to an FsCellsCollection. + /// Derives row- and columnIndex from the FsAddress of the FsCell. + static member addCell (cell : FsCell) (cellsCollection : FsCellsCollection) = + cellsCollection.Add(cell) + + /// Adds FsCells to the FsCellsCollection. + /// Derives row- and columnIndeces from the FsAddress of the FsCells. + member this.Add(cells : seq) = + cells |> Seq.iter (this.Add >> ignore) + this + + /// Adds FsCells to an FsCellsCollection. + /// Derives row- and columnIndeces from the FsAddress of the FsCells. + static member addCells (cells : seq) (cellsCollection : FsCellsCollection) = + cellsCollection.Add cells /// Checks if an FsCell exists at given row- and columnIndex. member this.ContainsCellAt(rowIndex, colIndex) =