Skip to content

Commit 7c115f9

Browse files
Merge branch 'dev'
2 parents 9711d0a + 1407621 commit 7c115f9

File tree

8 files changed

+42
-17
lines changed

8 files changed

+42
-17
lines changed

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+
## v3.4.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+
- Code maintenance
10+
11+
312
## v3.4.0
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>3.4.0</Version>
19-
<AssemblyVersion>3.4.0.0</AssemblyVersion>
20-
<FileVersion>3.4.0.0</FileVersion>
18+
<Version>3.4.1</Version>
19+
<AssemblyVersion>3.4.1.0</AssemblyVersion>
20+
<FileVersion>3.4.1.0</FileVersion>
2121
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
2222
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2323
<PackageTags>XLSX Excel ExcelWriter Office</PackageTags>

PicoXLSX/Cell.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public static IEnumerable<Cell> ConvertArray<T>(IEnumerable<T> list)
396396
Type t;
397397
foreach (T item in list)
398398
{
399-
if (item == null)
399+
if (object.Equals(item, default(T)))
400400
{
401401
c = new Cell(null, CellType.EMPTY);
402402
output.Add(c);
@@ -1002,11 +1002,23 @@ public override int GetHashCode()
10021002

10031003

10041004
// Operator overloads
1005+
/// <summary>
1006+
/// Compares two objects whether they are ranges and equal. The cell types (possible $ prefix) are considered. This method reflects <see cref="Equals(object)"/>
1007+
/// </summary>
1008+
/// <param name="range1">First range object</param>
1009+
/// <param name="range2">Second range object</param>
1010+
/// <returns>True, if both objects are equal, otherwise false</returns>
10051011
public static bool operator ==(Range range1, Range range2)
10061012
{
10071013
return range1.Equals(range2);
10081014
}
10091015

1016+
/// <summary>
1017+
/// Compares two objects whether they not equal. This method reflects the inverted method of <see cref="Equals(object)"/>
1018+
/// </summary>
1019+
/// <param name="range1">First range object</param>
1020+
/// <param name="range2">Second range object</param>
1021+
/// <returns>False, if both objects are equal, otherwise true</returns>
10101022
public static bool operator !=(Range range1, Range range2)
10111023
{
10121024
return !range1.Equals(range2);

PicoXLSX/LowLevel.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ namespace PicoXLSX
2222
/// </summary>
2323
internal class LowLevel
2424
{
25+
/// <summary>
26+
/// Threshold, using when floats are compared
27+
/// </summary>
28+
private const float FLOAT_THRESHOLD = 0.0001f;
29+
2530
/// <summary>
2631
/// Defines the WORKBOOK
2732
/// </summary>
@@ -916,7 +921,7 @@ private string CreateColsString(Worksheet worksheet)
916921
StringBuilder sb = new StringBuilder();
917922
foreach (KeyValuePair<int, Worksheet.Column> column in worksheet.Columns)
918923
{
919-
if (column.Value.Width == worksheet.DefaultColumnWidth && !column.Value.IsHidden) { continue; }
924+
if (Math.Abs(column.Value.Width - worksheet.DefaultColumnWidth) < FLOAT_THRESHOLD && !column.Value.IsHidden) { continue; }
920925
if (worksheet.Columns.ContainsKey(column.Key) && worksheet.Columns[column.Key].IsHidden)
921926
{
922927
hidden = " hidden=\"1\"";
@@ -997,7 +1002,7 @@ private string CreateRowString(DynamicRow dynamicRow, Worksheet worksheet)
9971002
int rowNumber = dynamicRow.RowNumber;
9981003
string height = "";
9991004
string hidden = "";
1000-
if (worksheet.RowHeights.ContainsKey(rowNumber) && worksheet.RowHeights[rowNumber] != worksheet.DefaultRowHeight)
1005+
if (worksheet.RowHeights.ContainsKey(rowNumber) && Math.Abs(worksheet.RowHeights[rowNumber] - worksheet.DefaultRowHeight) > FLOAT_THRESHOLD)
10011006
{
10021007
height = " x14ac:dyDescent=\"0.25\" customHeight=\"1\" ht=\"" + GetInternalRowHeight(worksheet.RowHeights[rowNumber]).ToString("G", culture) + "\"";
10031008
}

PicoXLSX/PicoXLSX.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/PicoXLSX/blob/master/Changelog.md for the release notes</PackageReleaseNotes>
2525
<PackageLicenseExpression>MIT</PackageLicenseExpression>
26-
<Version>3.4.0</Version>
27-
<AssemblyVersion>3.4.0.0</AssemblyVersion>
28-
<FileVersion>3.4.0.0</FileVersion>
26+
<Version>3.4.1</Version>
27+
<AssemblyVersion>3.4.1.0</AssemblyVersion>
28+
<FileVersion>3.4.1.0</FileVersion>
2929
<RepositoryType>git</RepositoryType>
3030
<GenerateDocumentationFile>True</GenerateDocumentationFile>
3131
</PropertyGroup>

PicoXLSX/Style.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2277,7 +2277,7 @@ internal static void AddPropertyAsJson(StringBuilder sb, string name, object val
22772277
sb.Append("\"").Append(name).Append("\": ");
22782278
if (value == null)
22792279
{
2280-
sb.Append("\"\"");
2280+
sb.Append("__null__");
22812281
}
22822282
else
22832283
{

PicoXLSX/Worksheet.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,11 +1868,7 @@ internal void RecalculateColumns()
18681868
List<int> columnsToDelete = new List<int>();
18691869
foreach (KeyValuePair<int, Column> col in columns)
18701870
{
1871-
if (!col.Value.HasAutoFilter && !col.Value.IsHidden && Math.Abs(col.Value.Width - DEFAULT_COLUMN_WIDTH) <= FLOAT_THRESHOLD)
1872-
{
1873-
columnsToDelete.Add(col.Key);
1874-
}
1875-
if (!col.Value.HasAutoFilter && !col.Value.IsHidden && Math.Abs(col.Value.Width - DEFAULT_COLUMN_WIDTH) <= FLOAT_THRESHOLD)
1871+
if (!col.Value.HasAutoFilter && !col.Value.IsHidden && Math.Abs(col.Value.Width - DEFAULT_COLUMN_WIDTH) <= FLOAT_THRESHOLD && col.Value.DefaultColumnStyle == null)
18761872
{
18771873
columnsToDelete.Add(col.Key);
18781874
}

README.md

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

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

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

0 commit comments

Comments
 (0)