Skip to content

Commit 7f12a94

Browse files
Update v2.6.2
1 parent ce5af41 commit 7f12a94

7 files changed

Lines changed: 58 additions & 19 deletions

File tree

Changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Change Log
22

3+
## v2.6.2
4+
5+
---
6+
Release Date: **24.01.2025**
7+
8+
- Fixed a regression bug in the Cell function ConvertArray
9+
- Added test cases
10+
11+
312
## v2.6.1
413

514
---

Demo/Demo.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1616
<TargetFrameworks>net45;net5.0</TargetFrameworks>
1717
<StartupObject>Demo.Program</StartupObject>
18-
<Version>2.6.1</Version>
19-
<AssemblyVersion>2.6.1.0</AssemblyVersion>
20-
<FileVersion>2.6.1.0</FileVersion>
18+
<Version>2.6.2</Version>
19+
<AssemblyVersion>2.6.2.0</AssemblyVersion>
20+
<FileVersion>2.6.2.0</FileVersion>
2121
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
2222
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2323
<PackageTags>XLSX Excel ExcelWriter ExcelReader Office</PackageTags>

NanoXLSX/Cell.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ public static IEnumerable<Cell> ConvertArray<T>(IEnumerable<T> list)
450450
Type t;
451451
foreach (T item in list)
452452
{
453-
if (object.Equals(item, default(T)))
453+
if (item == null) // DO NOT LISTEN to code suggestions! This is wrong for bool: if (object.Equals(item, default(T)))
454454
{
455455
c = new Cell(null, CellType.EMPTY);
456456
output.Add(c);

NanoXLSX/NanoXLSX.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
<PackageLicenseFile></PackageLicenseFile>
2424
<PackageReleaseNotes>Please see https://github.com/rabanti-github/NanoXLSX/blob/master/Changelog.md for the release notes</PackageReleaseNotes>
2525
<PackageLicenseExpression>MIT</PackageLicenseExpression>
26-
<Version>2.6.1</Version>
27-
<AssemblyVersion>2.6.1.0</AssemblyVersion>
28-
<FileVersion>2.6.1.0</FileVersion>
26+
<Version>2.6.2</Version>
27+
<AssemblyVersion>2.6.2.0</AssemblyVersion>
28+
<FileVersion>2.6.2.0</FileVersion>
2929
<RepositoryType>git</RepositoryType>
3030
<GenerateDocumentationFile>True</GenerateDocumentationFile>
3131
</PropertyGroup>

NanoXLSX/Worksheet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ public void InsertRow(int rowNumber, int numberOfNewRows)
14381438
var upperRow = this.GetRow(rowNumber);
14391439

14401440
// Identify all cells below the insertion point to adjust their addresses
1441-
var cellsToChange = this.Cells.Where(c => c.Value.CellAddress2.Row > rowNumber).ToList();
1441+
List<KeyValuePair<string, Cell>> cellsToChange = this.Cells.Where(c => c.Value.CellAddress2.Row > rowNumber).ToList();
14421442

14431443
// Make a copy of the cells to be moved and then delete the original cells;
14441444
Dictionary<string, Cell> newCells = new Dictionary<string, Cell>();

NanoXlsx Test/NanoXLSX Test.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
<PackageTags>Excel Office XLSX</PackageTags>
1818
<RepositoryType>git</RepositoryType>
1919
<PackageReleaseNotes>Please see https://github.com/rabanti-github/NanoXLSX/blob/master/Changelog.md for the release notes</PackageReleaseNotes>
20-
<Version>2.6.1</Version>
21-
<AssemblyVersion>2.6.1.0</AssemblyVersion>
22-
<FileVersion>2.6.1.0</FileVersion>
20+
<Version>2.6.2</Version>
21+
<AssemblyVersion>2.6.2.0</AssemblyVersion>
22+
<FileVersion>2.6.2.0</FileVersion>
2323
</PropertyGroup>
2424
<ItemGroup>
2525
<None Remove="Resources\autofilter.xlsx" />

NanoXlsx Test/Worksheets/WorksheetTest.cs

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,26 @@ public void ReplaceCellValue_ShouldReplaceAllOccurrences(object? oldValue, objec
15691569
Assert.Equal(differentValue, worksheet.Cells["D1"].Value);
15701570
}
15711571

1572+
[Fact(DisplayName = "Test of the ReplaceCellValue on an existing occurrence of a DateTime value")]
1573+
public void ReplaceCellValue_ShouldReplaceAllOccurrences2()
1574+
{
1575+
var worksheet = new Worksheet();
1576+
string oldValue = "oldValue";
1577+
worksheet.AddCell(oldValue, 0, 0);
1578+
worksheet.AddCell(oldValue, 1, 0);
1579+
worksheet.AddCell(oldValue, 2, 0);
1580+
worksheet.AddCell("differentValue", 3, 0);
1581+
1582+
DateTime newValue = new DateTime(2025, 02, 10, 5, 6, 7, DateTimeKind.Utc);
1583+
int replacedCount = worksheet.ReplaceCellValue(oldValue, newValue);
1584+
1585+
Assert.Equal(3, replacedCount);
1586+
Assert.Equal(newValue, worksheet.Cells["A1"].Value);
1587+
Assert.Equal(newValue, worksheet.Cells["B1"].Value);
1588+
Assert.Equal(newValue, worksheet.Cells["C1"].Value);
1589+
Assert.Equal("differentValue", worksheet.Cells["D1"].Value);
1590+
}
1591+
15721592
[Theory(DisplayName = "Test of the ReplaceCellValue when one existing values is to replace")]
15731593
[InlineData("oldValue", "newValue", "differentValue")]
15741594
[InlineData("oldValue", 23, true)]
@@ -1663,7 +1683,24 @@ public void FirstCellByValue_ShouldReturnCorrectCell(object? matchingValue)
16631683
{
16641684
var worksheet = new Worksheet();
16651685
var cell1 = new Cell("Test1", CellType.STRING, "A1");
1666-
var cell2 = new Cell(matchingValue, CellType.STRING, "B1");
1686+
var cell2 = new Cell(matchingValue, CellType.DEFAULT, "B1");
1687+
worksheet.Cells.Add("A1", cell1);
1688+
worksheet.Cells.Add("B1", cell2);
1689+
1690+
Cell? result = worksheet.FirstCellByValue(matchingValue);
1691+
1692+
Assert.NotNull(result);
1693+
Assert.Equal(matchingValue, ((Cell)result).Value);
1694+
Assert.Equal("B1", result.CellAddress);
1695+
}
1696+
1697+
[Fact(DisplayName = "Test of the FirstCellByValue when one existing values exists, on a DateTime value")]
1698+
public void FirstCellByValue_ShouldReturnCorrectCell2()
1699+
{
1700+
var worksheet = new Worksheet();
1701+
var cell1 = new Cell("Test1", CellType.STRING, "A1");
1702+
DateTime matchingValue = new DateTime(2025, 02, 10, 5, 6, 7, DateTimeKind.Utc);
1703+
var cell2 = new Cell(matchingValue, CellType.DATE, "B1");
16671704
worksheet.Cells.Add("A1", cell1);
16681705
worksheet.Cells.Add("B1", cell2);
16691706

@@ -1693,11 +1730,8 @@ public void FirstCellByValue_ShouldReturnNull_WhenValueNotFound(object? notMatch
16931730

16941731
Assert.Null(result);
16951732
}
1696-
1697-
16981733
#nullable disable
16991734

1700-
17011735
[Fact(DisplayName = "Test of the InsertRow function")]
17021736
public void TestInsertRow()
17031737
{
@@ -1769,12 +1803,8 @@ public void TestInsertColumn()
17691803
Assert.Null(worksheet.Cells["F2"].CellStyle);
17701804
Assert.Null(worksheet.Cells["H3"].CellStyle);
17711805
}
1772-
1773-
17741806
#endregion
17751807

1776-
1777-
17781808
public static Worksheet InitWorksheet(Worksheet worksheet, string address, Worksheet.CellDirection direction, Style style = null)
17791809
{
17801810
if (worksheet == null)

0 commit comments

Comments
 (0)