diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 64bee564..1a52d90a 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -1,3 +1,7 @@
+### 5.1.1+e7cc638 (Released 2024-1-26)
+* Additions:
+ * [[#e7cc638](https://github.com/CSBiology/FsSpreadsheet/commit/e7cc638b170c570005b6cd8378d1e0ac31075be7)] improve rowWithRange SkipSearch performance
+
### 5.1.0+4732d22 (Released 2024-1-24)
* Additions:
* Increase Parser speed
diff --git a/build/ReleaseTasks.fs b/build/ReleaseTasks.fs
index 0c4cf609..10bb74ff 100644
--- a/build/ReleaseTasks.fs
+++ b/build/ReleaseTasks.fs
@@ -62,7 +62,7 @@ let publishNPM = BuildTask.create "PublishNPM" [clean; build; runTests; packJS]
let msg = sprintf "[NPM] release package with version %s?" stableVersionTag
if promptYesNo msg then
let apikey = Environment.environVarOrNone "NPM_KEY"
- let otp = if apikey.IsSome then $" --otp + {apikey.Value}" else ""
+ let otp = if apikey.IsSome then $" --otp {apikey.Value}" else ""
run npm $"publish --access public{otp}" ProjectInfo.npmPkgDir
else failwith "aborted"
}
diff --git a/package.json b/package.json
index 4a3608e3..808e057e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@fslab/fsspreadsheet",
- "version": "5.1.0",
+ "version": "5.1.1",
"description": "Minimal spreadsheet creation and manipulation using exceljs io.",
"type": "module",
"main": "Xlsx.js",
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 @@
+