Skip to content

Commit 8937ed0

Browse files
Update v2.11.4
1 parent ebbcb70 commit 8937ed0

File tree

954 files changed

+1563
-1538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

954 files changed

+1563
-1538
lines changed

Changelog.md

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

3+
## v2.11.4
4+
5+
---
6+
Release Date: **27.03.2022**
7+
8+
- Fixed a follow-up issue on finding first/last cell addresses on explicitly defined, empty cells
9+
310
## v2.11.3
411

512
---

Demo .NET Standard/Demo .NET Standard.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<Copyright>Copyright Raphael Stoeckli © 2022</Copyright>
99
<RepositoryUrl>https://github.com/rabanti-github/PicoXLSX.git</RepositoryUrl>
1010
<PackageProjectUrl>https://github.com/rabanti-github/PicoXLSX</PackageProjectUrl>
11-
<AssemblyVersion>2.11.3.0</AssemblyVersion>
12-
<FileVersion>2.11.3.0</FileVersion>
13-
<Version>2.11.3</Version>
11+
<AssemblyVersion>2.11.4.0</AssemblyVersion>
12+
<FileVersion>2.11.4.0</FileVersion>
13+
<Version>2.11.4</Version>
1414
<Description>Demo Library showing the use of PicoXLSX, a library to generate Microsoft Excel files (XLSX) in an easy and native way</Description>
1515
<StartupObject>Demo.Program</StartupObject>
1616
<PackageLicenseExpression>MIT</PackageLicenseExpression>

Demo/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.11.3.0")]
36-
[assembly: AssemblyFileVersion("2.11.3.0")]
35+
[assembly: AssemblyVersion("2.11.4.0")]
36+
[assembly: AssemblyFileVersion("2.11.4.0")]

Documentation/CodeDocumentation.shfbproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<VisibleItems>InheritedMembers, InheritedFrameworkMembers, Internals, Privates, Protected, SealedProtected, ProtectedInternalAsProtected, EditorBrowsableNever, NonBrowsable</VisibleItems>
4242
<FeedbackEMailAddress>
4343
</FeedbackEMailAddress>
44-
<CopyrightText>Copyright Raphael Stoeckli &amp;#169%3b 2021</CopyrightText>
44+
<CopyrightText>Copyright Raphael Stoeckli &amp;#169%3b 2022</CopyrightText>
4545
<SaveComponentCacheCapacity>100</SaveComponentCacheCapacity>
4646
<WarnOnMissingSourceContext>False</WarnOnMissingSourceContext>
4747
<ProjectSummary>&amp;lt%3bp&amp;gt%3bPicoXLSX is a small .NET / C# library to create XLSX files %28Microsoft Excel 2007 or newer%29 in an easy and native way&amp;lt%3b/p&amp;gt%3b

PicoXLSX .NET Standard/PicoXLSX .NET Standard.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
55
<RootNamespace>PicoXLSX</RootNamespace>
66
<PackageId>PicoXLSX</PackageId>
7-
<Version>2.11.3</Version>
7+
<Version>2.11.4</Version>
88
<Authors>Raphael Stoeckli</Authors>
99
<Company>Raphael Stoeckli</Company>
1010
<Product>PicoXLSX</Product>
@@ -17,8 +17,8 @@
1717
<PackageTags>Excel Office XLSX</PackageTags>
1818
<PackageReleaseNotes>Please see https://github.com/rabanti-github/PicoXLSX/blob/master/Changelog.md for the release notes</PackageReleaseNotes>
1919
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
20-
<AssemblyVersion>2.11.3.0</AssemblyVersion>
21-
<FileVersion>2.11.3.0</FileVersion>
20+
<AssemblyVersion>2.11.4.0</AssemblyVersion>
21+
<FileVersion>2.11.4.0</FileVersion>
2222
</PropertyGroup>
2323

2424
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

PicoXLSX/LowLevel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,7 @@ public static string GeneratePasswordHash(string password)
16321632
/// <param name="date">Date to process</param>
16331633
/// <returns>Date or date and time as number</returns>
16341634
/// <exception cref="FormatException">Throws a FormatException if the passed date cannot be translated to the OADate format</exception>
1635-
/// <remarks>OAdate format starts at January 1st 1900 (actually 00.01.1900) and ends at December 31 9999. Values beyond these dates cannot be handled by Excel under normal circumstances and will throw a FormatException</remarks>
1635+
/// <remarks>OAdate format starts at January 1st 1900 (actually 00.01.1900) and ends at December 31 9999. Values after these dates cannot be handled by Excel under normal circumstances and will throw a FormatException</remarks>
16361636
public static string GetOADateTimeString(DateTime date)
16371637
{
16381638
if (date < FIRST_ALLOWED_EXCEL_DATE || date > LAST_ALLOWED_EXCEL_DATE)

PicoXLSX/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
// You can specify all the values or you can default the Build and Revision Numbers
3131
// by using the '*' as shown below:
3232
// [assembly: AssemblyVersion("1.0.*")]
33-
[assembly: AssemblyVersion("2.11.3")]
34-
[assembly: AssemblyFileVersion("2.11.3")]
33+
[assembly: AssemblyVersion("2.11.4")]
34+
[assembly: AssemblyFileVersion("2.11.4")]

PicoXLSX/Worksheet.cs

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,8 @@ public void ResetColumn(int columnNumber)
10931093
/// Gets the first existing column number in the current worksheet (zero-based)
10941094
/// </summary>
10951095
/// <returns>Zero-based column number. In case of an empty worksheet, -1 will be returned</returns>
1096-
/// <remarks>GetLastColumnNumber() will not return the last column with data in any case. If there is a formated but empty cell (or many) before the first cell with data,
1097-
/// GetLastColumnNumber() will return the column number of this empty cell. Use <see cref="GetFirstDataColumnNumber"/> in this case.</remarks>
1096+
/// <remarks>GetFirstColumnNumber() will not return the first column with data in any case. If there is a formatted but empty cell (or many) before the first cell with data,
1097+
/// GetFirstColumnNumber() will return the column number of this empty cell. Use <see cref="GetFirstDataColumnNumber"/> in this case.</remarks>
10981098
public int GetFirstColumnNumber()
10991099
{
11001100
return GetBoundaryNumber(false, true);
@@ -1108,14 +1108,14 @@ public int GetFirstColumnNumber()
11081108
/// If you want the first defined column, use <see cref="GetFirstColumnNumber"/> instead.</remarks>
11091109
public int GetFirstDataColumnNumber()
11101110
{
1111-
return GetBoundaryDataNumber(false, true);
1111+
return GetBoundaryDataNumber(false, true, true);
11121112
}
11131113

11141114
/// <summary>
11151115
/// Gets the first existing row number in the current worksheet (zero-based)
11161116
/// </summary>
11171117
/// <returns>Zero-based row number. In case of an empty worksheet, -1 will be returned</returns>
1118-
/// <remarks>GetFirstRowNumber() will not return the first row with data in any case. If there is a formated but empty cell (or many) before the first cell with data,
1118+
/// <remarks>GetFirstRowNumber() will not return the first row with data in any case. If there is a formatted but empty cell (or many) before the first cell with data,
11191119
/// GetFirstRowNumber() will return the row number of this empty cell. Use <see cref="GetFirstDataRowNumber"/> in this case.</remarks>
11201120
public int GetFirstRowNumber()
11211121
{
@@ -1126,19 +1126,19 @@ public int GetFirstRowNumber()
11261126
/// Gets the first existing row number with data in the current worksheet (zero-based)
11271127
/// </summary>
11281128
/// <returns>Zero-based row number. In case of an empty worksheet, -1 will be returned</returns>
1129-
/// <remarks>GetFirstDataColumnNumber() will ignore formatted but empty cells before the first column with data.
1130-
/// If you want the first defined column, use <see cref="GetFirstColumnNumber"/> instead.</remarks>
1129+
/// <remarks>GetFirstDataRowNumber() will ignore formatted but empty cells before the first row with data.
1130+
/// If you want the first defined row, use <see cref="GetFirstRowNumber"/> instead.</remarks>
11311131
public int GetFirstDataRowNumber()
11321132
{
1133-
return GetBoundaryDataNumber(true, true);
1133+
return GetBoundaryDataNumber(true, true, true);
11341134
}
11351135

11361136
/// <summary>
11371137
/// Gets the last existing column number in the current worksheet (zero-based)
11381138
/// </summary>
11391139
/// <returns>Zero-based column number. In case of an empty worksheet, -1 will be returned</returns>
11401140
/// <remarks>GetLastColumnNumber() will not return the last column with data in any case. If there is a formatted (or with the definition of AutoFilter,
1141-
/// column width or hidden state) but empty cell (or many) beyond the last cell with data,
1141+
/// column width or hidden state) but empty cell (or many) after the last cell with data,
11421142
/// GetLastColumnNumber() will return the column number of this empty cell. Use <see cref="GetLastDataColumnNumber"/> in this case.</remarks>
11431143
public int GetLastColumnNumber()
11441144
{
@@ -1149,19 +1149,19 @@ public int GetLastColumnNumber()
11491149
/// Gets the last existing column number with data in the current worksheet (zero-based)
11501150
/// </summary>
11511151
/// <returns>Zero-based column number. in case of an empty worksheet, -1 will be returned</returns>
1152-
/// <remarks>GetLastDataColumnNumber() will ignore formatted (or with the definition of AutoFilter, column width or hidden state) but empty cells beyond the last column with data.
1152+
/// <remarks>GetLastDataColumnNumber() will ignore formatted (or with the definition of AutoFilter, column width or hidden state) but empty cells after the last column with data.
11531153
/// If you want the last defined column, use <see cref="GetLastColumnNumber"/> instead.</remarks>
11541154
public int GetLastDataColumnNumber()
11551155
{
1156-
return GetBoundaryDataNumber(false, false);
1156+
return GetBoundaryDataNumber(false, false, true);
11571157
}
11581158

11591159
/// <summary>
11601160
/// Gets the last existing row number in the current worksheet (zero-based)
11611161
/// </summary>
11621162
/// <returns>Zero-based row number. In case of an empty worksheet, -1 will be returned</returns>
11631163
/// <remarks>GetLastRowNumber() will not return the last row with data in any case. If there is a formatted (or with the definition of row height or hidden state)
1164-
/// but empty cell (or many) beyond the last cell with data,
1164+
/// but empty cell (or many) after the last cell with data,
11651165
/// GetLastRowNumber() will return the row number of this empty cell. Use <see cref="GetLastDataRowNumber"/> in this case.</remarks>
11661166
public int GetLastRowNumber()
11671167
{
@@ -1173,19 +1173,19 @@ public int GetLastRowNumber()
11731173
/// Gets the last existing row number with data in the current worksheet (zero-based)
11741174
/// </summary>
11751175
/// <returns>Zero-based row number. in case of an empty worksheet, -1 will be returned</returns>
1176-
/// <remarks>GetLastDataColumnNumber() will ignore formatted (or with the definition of row height or hidden state) but empty cells beyond the last column with data.
1176+
/// <remarks>GetLastDataColumnNumber() will ignore formatted (or with the definition of row height or hidden state) but empty cells after the last column with data.
11771177
/// If you want the last defined column, use <see cref="GetLastRowNumber"/> instead.</remarks>
11781178
public int GetLastDataRowNumber()
11791179
{
1180-
return GetBoundaryDataNumber(true, false);
1180+
return GetBoundaryDataNumber(true, false, true);
11811181
}
11821182

11831183
/// <summary>
11841184
/// Gets the last existing cell in the current worksheet (bottom right)
11851185
/// </summary>
11861186
/// <returns>Nullable Cell Address. If no cell address could be determined, null will be returned</returns>
11871187
/// <remarks>GetLastCellAddress() will not return the last cell with data in any case. If there is a formatted (or with definitions of hidden states, AutoFilters, heights or widths)
1188-
/// but empty cell (or many) beyond the last cell with data,
1188+
/// but empty cell (or many) after the last cell with data,
11891189
/// GetLastCellAddress() will return the address of this empty cell. Use <see cref="GetLastDataCellAddress"/> in this case.</remarks>
11901190

11911191
public Cell.Address? GetLastCellAddress()
@@ -1203,7 +1203,7 @@ public int GetLastDataRowNumber()
12031203
/// Gets the last existing cell with data in the current worksheet (bottom right)
12041204
/// </summary>
12051205
/// <returns>Nullable Cell Address. If no cell address could be determined, null will be returned</returns>
1206-
/// <remarks>GetLastDataCellAddress() will ignore formatted (or with definitions of hidden states, AutoFilters, heights or widths) but empty cells beyond the last cell with data.
1206+
/// <remarks>GetLastDataCellAddress() will ignore formatted (or with definitions of hidden states, AutoFilters, heights or widths) but empty cells after the last cell with data.
12071207
/// If you want the last defined cell, use <see cref="GetLastCellAddress"/> instead.</remarks>
12081208

12091209
public Cell.Address? GetLastDataCellAddress()
@@ -1221,7 +1221,7 @@ public int GetLastDataRowNumber()
12211221
/// Gets the first existing cell in the current worksheet (bottom right)
12221222
/// </summary>
12231223
/// <returns>Nullable Cell Address. If no cell address could be determined, null will be returned</returns>
1224-
/// <remarks>GetFirstCellAddress() will not return the first cell with data in any case. If there is a formated but empty cell (or many) before the first cell with data,
1224+
/// <remarks>GetFirstCellAddress() will not return the first cell with data in any case. If there is a formatted but empty cell (or many) before the first cell with data,
12251225
/// GetLastCellAddress() will return the address of this empty cell. Use <see cref="GetFirstDataCellAddress"/> in this case.</remarks>
12261226
public Cell.Address? GetFirstCellAddress()
12271227
{
@@ -1256,37 +1256,54 @@ public int GetLastDataRowNumber()
12561256
/// </summary>
12571257
/// <param name="row">If true, the min or max row is returned, otherwise the column</param>
12581258
/// <param name="min">If true, the min value of the row or column is defined, otherwise the max value</param>
1259+
/// <param name="ignoreEmpty">If true, empty cell values are ignored, otherwise considered without checking the content</param>
12591260
/// <returns>Min or max number, or -1 if not defined</returns>
1260-
private int GetBoundaryDataNumber(bool row, bool min)
1261+
private int GetBoundaryDataNumber(bool row, bool min, bool ignoreEmpty)
12611262
{
12621263
if (cells.Count == 0)
12631264
{
12641265
return -1;
12651266
}
1266-
else
1267+
if (!ignoreEmpty)
12671268
{
1268-
List<Cell> nonEmptyCells = cells.Values.Where(x => x.Value != null).ToList();
1269-
if (nonEmptyCells.Count == 0)
1270-
{
1271-
return -1;
1272-
}
12731269
if (row && min)
12741270
{
1275-
return nonEmptyCells.Where(x => x.Value.ToString() != string.Empty).Min(x => x.RowNumber);
1271+
return cells.Min(x => x.Value.RowNumber);
12761272
}
12771273
else if (row)
12781274
{
1279-
return nonEmptyCells.Where(x => x.Value.ToString() != string.Empty).Max(x => x.RowNumber);
1275+
return cells.Max(x => x.Value.RowNumber);
12801276
}
12811277
else if (min)
12821278
{
1283-
return nonEmptyCells.Where(x => x.Value.ToString() != string.Empty).Max(x => x.ColumnNumber);
1279+
return cells.Min(x => x.Value.ColumnNumber);
12841280
}
12851281
else
12861282
{
1287-
return nonEmptyCells.Where(x => x.Value.ToString() != string.Empty).Min(x => x.ColumnNumber);
1283+
return cells.Max(x => x.Value.ColumnNumber);
12881284
}
12891285
}
1286+
List<Cell> nonEmptyCells = cells.Values.Where(x => x.Value != null).ToList();
1287+
if (nonEmptyCells.Count == 0)
1288+
{
1289+
return -1;
1290+
}
1291+
if (row && min)
1292+
{
1293+
return nonEmptyCells.Where(x => x.Value.ToString() != string.Empty).Min(x => x.RowNumber);
1294+
}
1295+
else if (row)
1296+
{
1297+
return nonEmptyCells.Where(x => x.Value.ToString() != string.Empty).Max(x => x.RowNumber);
1298+
}
1299+
else if (min)
1300+
{
1301+
return nonEmptyCells.Where(x => x.Value.ToString() != string.Empty).Max(x => x.ColumnNumber);
1302+
}
1303+
else
1304+
{
1305+
return nonEmptyCells.Where(x => x.Value.ToString() != string.Empty).Min(x => x.ColumnNumber);
1306+
}
12901307
}
12911308

12921309
/// <summary>
@@ -1297,7 +1314,7 @@ private int GetBoundaryDataNumber(bool row, bool min)
12971314
/// <returns>Min or max number, or -1 if not defined</returns>
12981315
private int GetBoundaryNumber(bool row, bool min)
12991316
{
1300-
int cellBoundary = GetBoundaryDataNumber(row, min);
1317+
int cellBoundary = GetBoundaryDataNumber(row, min, false);
13011318
if (row)
13021319
{
13031320
int heightBoundary = -1;

docs/Documentation.chm

-756 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)