From 0f443f1a700d272f1942c57486151e7f68da431d Mon Sep 17 00:00:00 2001 From: omaus Date: Thu, 23 Mar 2023 22:35:56 +0100 Subject: [PATCH] Replace unallowed constructor pattern --- src/FsSpreadsheet.ExcelIO/Spreadsheet.fs | 1 + src/FsSpreadsheet/FsRow.fs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/FsSpreadsheet.ExcelIO/Spreadsheet.fs b/src/FsSpreadsheet.ExcelIO/Spreadsheet.fs index f9523ff7..085e0815 100644 --- a/src/FsSpreadsheet.ExcelIO/Spreadsheet.fs +++ b/src/FsSpreadsheet.ExcelIO/Spreadsheet.fs @@ -51,6 +51,7 @@ module Spreadsheet = /// /// Closes the FileStream to the spreadsheet. + /// let close (spreadsheet : SpreadsheetDocument) = spreadsheet.Close() /// diff --git a/src/FsSpreadsheet/FsRow.fs b/src/FsSpreadsheet/FsRow.fs index 1568bd5f..de26a669 100644 --- a/src/FsSpreadsheet/FsRow.fs +++ b/src/FsSpreadsheet/FsRow.fs @@ -1,5 +1,6 @@ namespace FsSpreadsheet + // Type based on the type XLRow used in ClosedXml /// /// Creates an FsRow from the given FsRangeAddress, consisting of FsCells within a given FsCellsCollection, and a styleValue. @@ -20,12 +21,13 @@ type FsRow (rangeAddress : FsRangeAddress, cells : FsCellsCollection, styleValue /// The appropriate range of the cells (i.e. minimum colIndex and maximum colIndex) is derived from the FsCells with the matching rowIndex. new (index, (cells : FsCellsCollection)) = let getIndexBy (f : (FsCell -> int) -> seq -> 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)