Skip to content

Commit ba59f86

Browse files
Update v2.6.1
1 parent 1857c2f commit ba59f86

File tree

8 files changed

+39
-25
lines changed

8 files changed

+39
-25
lines changed

Changelog.md

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

3+
## v2.6.1
4+
5+
---
6+
Release Date: **19.01.2025**
7+
8+
- Fixed a bug on writing default column widths (not persisted in some cases)
9+
- Adapted style reader: When a workbook is loaded, not defined color values of Border styles are now empty strings (were null), as if a new style is created
10+
- Code maintenance
11+
12+
Note: The color values of Border styles are handled identical on writing XLSX files, either if null or empty. The change of the reader behavior was to enforce the "What You Can Write Is What You Can Read" policy of the library (writing an empty string as color value should lead to an empty string on read).
13+
314
## v2.6.0
415

516
---

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.0</Version>
19-
<AssemblyVersion>2.6.0.0</AssemblyVersion>
20-
<FileVersion>2.6.0.0</FileVersion>
18+
<Version>2.6.1</Version>
19+
<AssemblyVersion>2.6.1.0</AssemblyVersion>
20+
<FileVersion>2.6.1.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 (item == null)
453+
if (object.Equals(item, default(T)))
454454
{
455455
c = new Cell(null, CellType.EMPTY);
456456
output.Add(c);

NanoXLSX/LowLevel/XlsxWriter.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ namespace NanoXLSX.LowLevel
2828
/// <remarks>This class is only for internal use. Use the high level API (e.g. class Workbook) to manipulate data and create Excel files</remarks>
2929
class XlsxWriter
3030
{
31+
#region constants
32+
/// <summary>
33+
/// Threshold, using when floats are compared
34+
/// </summary>
35+
private const float FLOAT_THRESHOLD = 0.0001f;
36+
#endregion
37+
3138

3239
#region staticFields
3340
private static DocumentPath WORKBOOK = new DocumentPath("workbook.xml", "xl/");
@@ -823,7 +830,7 @@ private string CreateColsString(Worksheet worksheet)
823830
StringBuilder sb = new StringBuilder();
824831
foreach (KeyValuePair<int, Column> column in worksheet.Columns)
825832
{
826-
if (column.Value.Width == worksheet.DefaultColumnWidth && !column.Value.IsHidden && column.Value.DefaultColumnStyle == null) { continue; }
833+
if (Math.Abs(column.Value.Width - worksheet.DefaultColumnWidth) < FLOAT_THRESHOLD && !column.Value.IsHidden && column.Value.DefaultColumnStyle == null) { continue; }
827834
if (worksheet.Columns.ContainsKey(column.Key))
828835
{
829836
if (worksheet.Columns[column.Key].IsHidden)
@@ -907,19 +914,13 @@ private string CreateRowString(DynamicRow dynamicRow, Worksheet worksheet)
907914
int rowNumber = dynamicRow.RowNumber;
908915
string height = "";
909916
string hidden = "";
910-
if (worksheet.RowHeights.ContainsKey(rowNumber))
917+
if (worksheet.RowHeights.ContainsKey(rowNumber) && Math.Abs(worksheet.RowHeights[rowNumber] - worksheet.DefaultRowHeight) > FLOAT_THRESHOLD)
911918
{
912-
if (worksheet.RowHeights[rowNumber] != worksheet.DefaultRowHeight)
913-
{
914-
height = " x14ac:dyDescent=\"0.25\" customHeight=\"1\" ht=\"" + Utils.GetInternalRowHeight(worksheet.RowHeights[rowNumber]).ToString("G", culture) + "\"";
915-
}
919+
height = " x14ac:dyDescent=\"0.25\" customHeight=\"1\" ht=\"" + Utils.GetInternalRowHeight(worksheet.RowHeights[rowNumber]).ToString("G", culture) + "\"";
916920
}
917-
if (worksheet.HiddenRows.ContainsKey(rowNumber))
921+
if (worksheet.HiddenRows.ContainsKey(rowNumber) && worksheet.HiddenRows[rowNumber])
918922
{
919-
if (worksheet.HiddenRows[rowNumber])
920-
{
921-
hidden = " hidden=\"1\"";
922-
}
923+
hidden = " hidden=\"1\"";
923924
}
924925
StringBuilder sb = new StringBuilder();
925926
sb.Append("<row r=\"").Append((rowNumber + 1).ToString()).Append("\"").Append(height).Append(hidden).Append(">");

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.0</Version>
27-
<AssemblyVersion>2.6.0.0</AssemblyVersion>
28-
<FileVersion>2.6.0.0</FileVersion>
26+
<Version>2.6.1</Version>
27+
<AssemblyVersion>2.6.1.0</AssemblyVersion>
28+
<FileVersion>2.6.1.0</FileVersion>
2929
<RepositoryType>git</RepositoryType>
3030
<GenerateDocumentationFile>True</GenerateDocumentationFile>
3131
</PropertyGroup>

NanoXLSX/Worksheet.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using System.Text;
1212
using System.Text.RegularExpressions;
1313
using NanoXLSX.Exceptions;
14-
using NanoXLSX.LowLevel;
1514
using NanoXLSX.Styles;
1615
using FormatException = NanoXLSX.Exceptions.FormatException;
1716

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.0</Version>
21-
<AssemblyVersion>2.6.0.0</AssemblyVersion>
22-
<FileVersion>2.6.0.0</FileVersion>
20+
<Version>2.6.1</Version>
21+
<AssemblyVersion>2.6.1.0</AssemblyVersion>
22+
<FileVersion>2.6.1.0</FileVersion>
2323
</PropertyGroup>
2424
<ItemGroup>
2525
<None Remove="Resources\autofilter.xlsx" />

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
# NanoXLSX ![NanoXLSX](https://github.com/rabanti-github/NanoXLSX/blob/master/Documentation/icons/NanoXLSX.png)
1+
![NanoXLSX](https://raw.githubusercontent.com/rabanti-github/NanoXLSX/refs/heads/master/Documentation/icons/NanoXLSX.png)
22

3-
![nuget](https://img.shields.io/nuget/v/NanoXLSX.svg?maxAge=86400)
4-
![license](https://img.shields.io/github/license/rabanti-github/NanoXlsx.svg)
3+
# NanoXLSX
4+
5+
![NuGet Version](https://img.shields.io/nuget/v/NanoXLSX)
6+
![NuGet Downloads](https://img.shields.io/nuget/dt/NanoXLSX)
7+
![GitHub License](https://img.shields.io/github/license/rabanti-github/NanoXLSX)
58
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Frabanti-github%2FNanoXLSX.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Frabanti-github%2FNanoXLSX?ref=badge_shield)
69

710
NanoXLSX is a small .NET library written in C#, to create and read Microsoft Excel files in the XLSX format (Microsoft Excel 2007 or newer) in an easy and native way

0 commit comments

Comments
 (0)