Skip to content

Commit

Permalink
Replace unallowed constructor pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
omaus committed Mar 23, 2023
1 parent b52ec35 commit 0f443f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/FsSpreadsheet.ExcelIO/Spreadsheet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module Spreadsheet =

/// <summary>
/// Closes the FileStream to the spreadsheet.
/// </summary>
let close (spreadsheet : SpreadsheetDocument) = spreadsheet.Close()

/// <summary>
Expand Down
6 changes: 4 additions & 2 deletions src/FsSpreadsheet/FsRow.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace FsSpreadsheet


// Type based on the type XLRow used in ClosedXml
/// <summary>
/// Creates an FsRow from the given FsRangeAddress, consisting of FsCells within a given FsCellsCollection, and a styleValue.
Expand All @@ -20,12 +21,13 @@ type FsRow (rangeAddress : FsRangeAddress, cells : FsCellsCollection, styleValue
/// <remarks>The appropriate range of the cells (i.e. minimum colIndex and maximum colIndex) is derived from the FsCells with the matching rowIndex.</remarks>
new (index, (cells : FsCellsCollection)) =
let getIndexBy (f : (FsCell -> int) -> seq<FsCell> -> FsCell) =
try
match cells.GetCellsInRow index |> Seq.length with
| 0 -> 0
| _ ->
(
cells.GetCellsInRow index
|> f (fun c -> c.Address.ColumnNumber)
).Address.ColumnNumber
with :? System.ArgumentException -> 0
let minColIndex = getIndexBy Seq.minBy
let maxColIndex = getIndexBy Seq.maxBy
FsRow (FsRangeAddress(FsAddress(index, minColIndex),FsAddress(index, maxColIndex)), cells, null)
Expand Down

0 comments on commit 0f443f1

Please sign in to comment.