diff --git a/src/FsSpreadsheet/FsWorksheet.fs b/src/FsSpreadsheet/FsWorksheet.fs
index c9323ffc..1473c198 100644
--- a/src/FsSpreadsheet/FsWorksheet.fs
+++ b/src/FsSpreadsheet/FsWorksheet.fs
@@ -132,7 +132,13 @@ type FsWorksheet (name, ?fsRows, ?fsTables, ?fsCellsCollection) =
///
/// Returns the FsRow at the given index. If it does not exist, it is created and appended first.
///
- member self.Row(rowIndex) =
+ member self.Row(rowIndex, ?SkipSearch) =
+ let skipSearch = defaultArg SkipSearch false
+ if skipSearch then
+ let row = FsRow.createAt(rowIndex,self.CellCollection)
+ _rows.Add row
+ row
+ else
match _rows |> Seq.tryFind (fun row -> row.Index = rowIndex) with
| Some row ->
row
@@ -150,7 +156,7 @@ type FsWorksheet (name, ?fsRows, ?fsTables, ?fsCellsCollection) =
if rangeAddress.FirstAddress.RowNumber <> rangeAddress.LastAddress.RowNumber then
failwithf "Row may not have a range address spanning over different row indices"
if skipSearch then
- let row = FsRow.createAt(rangeAddress.FirstAddress.RowNumber,self.CellCollection)
+ let row = FsRow (rangeAddress, self.CellCollection)
row.RangeAddress <- rangeAddress
_rows.Add row
row
diff --git a/tests/FsSpreadsheet.Tests/FsRowTests.fs b/tests/FsSpreadsheet.Tests/FsRowTests.fs
index 2650de62..05a94aa4 100644
--- a/tests/FsSpreadsheet.Tests/FsRowTests.fs
+++ b/tests/FsSpreadsheet.Tests/FsRowTests.fs
@@ -1,6 +1,6 @@
module FsRow
-
+open TestingUtils
#if FABLE_COMPILER
open Fable.Mocha
#else
@@ -17,7 +17,27 @@ let getDummyWorkSheet() =
worksheet.RescanRows()
worksheet
-let main =
+
+let performace =
+ testList "performance" [
+ testCase "FrowFromRange-SkipSearch" (fun () ->
+ let rowCount= 100000
+ let ws = FsWorksheet.init("MyWorksheet")
+ let timer = Stopwatch()
+ timer.Start()
+ for i = 1 to rowCount do
+ let address = FsRangeAddress(FsAddress(i,1), FsAddress(i,1))
+ ws.RowWithRange(address,true) |> ignore
+ timer.Stop()
+ let runtime = timer.Elapsed.Milliseconds
+ let expected = 50 // this is too high and should be reduced
+
+ Expect.equal ws.Rows.Count rowCount "Row count"
+ Expect.isTrue (runtime <= expected) $"Expected conversion to be finished in under {expected}, but it took {runtime}"
+ )
+ ]
+
+let rowOperations =
testList "rowOperations" [
testList "Prerequisites" [
let dummyWorkSheet = getDummyWorkSheet()
@@ -117,3 +137,9 @@ let main =
Expect.equal maxColIndex 1 "Incorrect index"
]
]
+
+let main =
+ testList "FsRow" [
+ rowOperations
+ performace
+ ]
diff --git a/tests/FsSpreadsheet.Tests/FsSpreadsheet.Tests.fsproj b/tests/FsSpreadsheet.Tests/FsSpreadsheet.Tests.fsproj
index 6a6418a2..d07df6d7 100644
--- a/tests/FsSpreadsheet.Tests/FsSpreadsheet.Tests.fsproj
+++ b/tests/FsSpreadsheet.Tests/FsSpreadsheet.Tests.fsproj
@@ -31,6 +31,7 @@
+