Skip to content

Commit

Permalink
Update v3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rabanti-github committed Aug 9, 2023
1 parent 2b44c2d commit d84bd82
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 60 deletions.
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## v3.1.1

---
Release Date: **10.08.2023**

- Adapted hex color validation (clarified number of necessary characters)
- Code maintenance

## v3.1.0

---
Expand Down
8 changes: 4 additions & 4 deletions Demo .NET Standard/Demo .NET Standard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>PicoXLSX</RootNamespace>
<AssemblyName>PicoXLSX.Demo</AssemblyName>
<Copyright>Copyright Raphael Stoeckli © 2022</Copyright>
<Copyright>Copyright Raphael Stoeckli © 2023</Copyright>
<RepositoryUrl>https://github.com/rabanti-github/PicoXLSX.git</RepositoryUrl>
<PackageProjectUrl>https://github.com/rabanti-github/PicoXLSX</PackageProjectUrl>
<AssemblyVersion>3.1.0.0</AssemblyVersion>
<FileVersion>3.1.0.0</FileVersion>
<Version>3.1.0</Version>
<AssemblyVersion>3.1.1.0</AssemblyVersion>
<FileVersion>3.1.1.0</FileVersion>
<Version>3.1.1</Version>
<Description>Demo Library showing the use of PicoXLSX, a library to generate Microsoft Excel files (XLSX) in an easy and native way</Description>
<StartupObject>Demo.Program</StartupObject>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
2 changes: 1 addition & 1 deletion Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Demo
{
class Program
static class Program
{
/// <summary>
/// Method to run all demos / testing scenarios (currently disabled)
Expand Down
4 changes: 2 additions & 2 deletions Demo/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.1.0.0")]
[assembly: AssemblyFileVersion("3.1.0.0")]
[assembly: AssemblyVersion("3.1.1.0")]
[assembly: AssemblyFileVersion("3.1.1.0")]
12 changes: 6 additions & 6 deletions Demo/Testing/Performance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ namespace Demo.Testing
/// <summary>
/// Class for performance tests
/// </summary>
public class Performance
public static class Performance
{
/// <summary>
/// Method to perform a stress test on PicoXLSX with a high amount of random data
/// </summary>
/// <param name="filename">filename of the output</param>
/// <param name="sheetname">name of the worksheet</param>
/// <param name="sheetName">name of the worksheet</param>
/// <param name="rows">Number of rows</param>
/// <param name="cols">Number of columns</param>
/// <remarks>The data type is determined per column randomly. In case of strings, random ASCII characters from 1 to 256 characters are written into the cells</remarks>
public static void StressTest(string filename, string sheetname, int rows, int cols)
public static void StressTest(string filename, string sheetName, int rows, int cols)
{
System.Console.WriteLine("Starting performance test - Generating Array...");
List<List<object>> field = new List<List<object>>();
List<object> row;
List<int> colTypes = new List<int>();
DateTime min = new DateTime(1901, 01, 01);
DateTime max = new DateTime(2100, 01, 01);
DateTime min = new DateTime(1901, 1, 1, 0, 0, 0, DateTimeKind.Unspecified);
DateTime max = new DateTime(2100, 1, 1, 0, 0, 0, DateTimeKind.Unspecified);
int j;
for (int i = 0; i < cols; i++)
{
Expand All @@ -56,7 +56,7 @@ public static void StressTest(string filename, string sheetname, int rows, int c
field.Add(row);
}
System.Console.WriteLine("Writing cells...");
PicoXLSX.Workbook b = new PicoXLSX.Workbook(filename, sheetname);
PicoXLSX.Workbook b = new PicoXLSX.Workbook(filename, sheetName);
PicoXLSX.Worksheet s = b.CurrentWorksheet;
s.CurrentCellDirection = PicoXLSX.Worksheet.CellDirection.ColumnToColumn;
for (int i = 0; i < rows; i++)
Expand Down
2 changes: 1 addition & 1 deletion Demo/Testing/TypeTesting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Demo.Testing
/// <summary>
/// Class for testing of several data types
/// </summary>
public class TypeTesting
public static class TypeTesting
{

public static void NumericTypeTesting(string fileName)
Expand Down
8 changes: 4 additions & 4 deletions PicoXLSX .NET Standard/PicoXLSX .NET Standard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<RootNamespace>PicoXLSX</RootNamespace>
<PackageId>PicoXLSX</PackageId>
<Version>3.1.0</Version>
<Version>3.1.1</Version>
<Authors>Raphael Stoeckli</Authors>
<Company></Company>
<Product>PicoXLSX</Product>
<Description>PicoXLSX is a library to generate Microsoft Excel files (XLSX) in an easy and native way</Description>
<Copyright>Copyright Raphael Stoeckli © 2022</Copyright>
<Copyright>Copyright Raphael Stoeckli © 2023</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/rabanti-github/PicoXLSX</PackageProjectUrl>
<PackageIcon>PicoXLSX.png</PackageIcon>
<RepositoryUrl>https://github.com/rabanti-github/PicoXLSX.git</RepositoryUrl>
<PackageTags>Excel Office XLSX</PackageTags>
<PackageReleaseNotes>Please see https://github.com/rabanti-github/PicoXLSX/blob/master/Changelog.md for the release notes</PackageReleaseNotes>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyVersion>3.1.0.0</AssemblyVersion>
<FileVersion>3.1.0.0</FileVersion>
<AssemblyVersion>3.1.1.0</AssemblyVersion>
<FileVersion>3.1.1.0</FileVersion>
<AssemblyName>PicoXLSX</AssemblyName>
<ApplicationIcon>favicon.ico</ApplicationIcon>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions PicoXLSX/Cell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ public struct Address : IEquatable<Address>, IComparable<Address>
public AddressType Type;

/// <summary>
/// Initializes a new instance of the <see cref=""/> class
/// Initializes a new instance of the <see cref="Address"/> class
/// </summary>
/// <param name="column">Column number (zero based).</param>
/// <param name="row">Row number (zero based).</param>
Expand All @@ -749,7 +749,7 @@ public Address(int column, int row, AddressType type = AddressType.Default)
}

/// <summary>
/// Initializes a new instance of the <see cref=""/> class
/// Initializes a new instance of the <see cref="Address"/> class
/// </summary>
/// <param name="address">Address string (e.g. 'A1:B12').</param>
/// <param name="type">Optional referencing type of the address.</param>
Expand Down Expand Up @@ -869,7 +869,7 @@ public struct Range
public Address StartAddress;

/// <summary>
/// Initializes a new instance of the <see cref=""/> class
/// Initializes a new instance of the <see cref="Range"/> class
/// </summary>
/// <param name="start">Start address of the range.</param>
/// <param name="end">End address of the range.</param>
Expand All @@ -888,7 +888,7 @@ public Range(Address start, Address end)
}

/// <summary>
/// Initializes a new instance of the <see cref=""/> class
/// Initializes a new instance of the <see cref="Range"/> class
/// </summary>
/// <param name="range">Address range (e.g. 'A1:B12').</param>
public Range(string range)
Expand Down
17 changes: 7 additions & 10 deletions PicoXLSX/LowLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ internal class LowLevel
/// <summary>
/// First date that can be displayed by Excel. Real values before this date cannot be processed.
/// </summary>
public static readonly DateTime FIRST_ALLOWED_EXCEL_DATE = new DateTime(1900, 1, 1, 0, 0, 0);
public static readonly DateTime FIRST_ALLOWED_EXCEL_DATE = new DateTime(1900, 1, 1, 0, 0, 0, DateTimeKind.Unspecified);

/// <summary>
/// All dates before this date are shifted in Excel by -1.0, since Excel assumes wrongly that the year 1900 is a leap year.<br/>
/// See also: <a href="https://docs.microsoft.com/en-us/office/troubleshoot/excel/wrongly-assumes-1900-is-leap-year">
/// https://docs.microsoft.com/en-us/office/troubleshoot/excel/wrongly-assumes-1900-is-leap-year</a>
/// </summary>
public static readonly DateTime FIRST_VALID_EXCEL_DATE = new DateTime(1900, 3, 1);
public static readonly DateTime FIRST_VALID_EXCEL_DATE = new DateTime(1900, 3, 1, 0, 0, 0, DateTimeKind.Unspecified);

/// <summary>
/// Last date that can be displayed by Excel. Real values after this date cannot be processed.
/// </summary>
public static readonly DateTime LAST_ALLOWED_EXCEL_DATE = new DateTime(9999, 12, 31, 23, 59, 59);
public static readonly DateTime LAST_ALLOWED_EXCEL_DATE = new DateTime(9999, 12, 31, 23, 59, 59, DateTimeKind.Unspecified);

/// <summary>
/// Constant for number conversion. The invariant culture (represents mostly the US numbering scheme) ensures that no culture-specific
Expand Down Expand Up @@ -125,7 +125,7 @@ internal class LowLevel
/// <summary>
/// Defines the ROOT_MILLIS
/// </summary>
private static readonly double ROOT_MILLIS = (double)new DateTime(1899, 12, 30, 0, 0, 0).Ticks / TimeSpan.TicksPerMillisecond;
private static readonly double ROOT_MILLIS = (double)new DateTime(1899, 12, 30, 0, 0, 0, DateTimeKind.Unspecified).Ticks / TimeSpan.TicksPerMillisecond;

/// <summary>
/// Defines the culture
Expand Down Expand Up @@ -733,7 +733,7 @@ public void SaveAsStream(Stream stream, bool leaveOpen = false)
else
{
pp = p.CreatePart(sheetURIs[i], @"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml", CompressionOption.Normal);
i++;

AppendXmlToPackagePart(CreateWorksheetPart(new Worksheet("sheet1")), pp);
}
pp = p.CreatePart(sharedStringsUri, @"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml", CompressionOption.Normal);
Expand Down Expand Up @@ -1003,15 +1003,12 @@ private string CreateRowString(DynamicRow dynamicRow, Worksheet worksheet)
// Date parsing
else if (item.DataType == Cell.CellType.DATE)
{
typeAttribute = "d";
DateTime date = (DateTime)item.Value;
valueDef = GetOADateTimeString(date);
}
// Time parsing
else if (item.DataType == Cell.CellType.TIME)
{
typeAttribute = "d";
// TODO: 'd' is probably an outdated attribute (to be checked for dates and times)
TimeSpan time = (TimeSpan)item.Value;
valueDef = GetOATimeString(time);
}
Expand Down Expand Up @@ -1791,12 +1788,12 @@ public static float GetInternalPaneSplitHeight(float height)
/// <summary>
/// Class representing a row that is either empty or containing cells. Empty rows can also carry information about height or visibility
/// </summary>
private class DynamicRow
private sealed class DynamicRow
{
/// <summary>
/// Defines the cellDefinitions
/// </summary>
private List<Cell> cellDefinitions;
private readonly List<Cell> cellDefinitions;

/// <summary>
/// Gets or sets the row number (zero-based)
Expand Down
4 changes: 2 additions & 2 deletions PicoXLSX/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.1.0")]
[assembly: AssemblyFileVersion("3.1.0")]
[assembly: AssemblyVersion("3.1.1")]
[assembly: AssemblyFileVersion("3.1.1")]
19 changes: 9 additions & 10 deletions PicoXLSX/Style.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,10 +1026,10 @@ public Fill(string foreground, string background)
/// Initializes a new instance of the <see cref="Fill"/> class
/// </summary>
/// <param name="value">Color value.</param>
/// <param name="filltype">Fill type (fill or pattern).</param>
public Fill(string value, FillType filltype)
/// <param name="fillType">Fill type (fill or pattern).</param>
public Fill(string value, FillType fillType)
{
if (filltype == FillType.fillColor)
if (fillType == FillType.fillColor)
{
backgroundColor = DEFAULT_COLOR;
ForegroundColor = value;
Expand Down Expand Up @@ -1101,10 +1101,10 @@ public Fill CopyFill()
/// Sets the color and the depending fill type
/// </summary>
/// <param name="value">color value.</param>
/// <param name="filltype">fill type (fill or pattern).</param>
public void SetColor(string value, FillType filltype)
/// <param name="fillType">fill type (fill or pattern).</param>
public void SetColor(string value, FillType fillType)
{
if (filltype == FillType.fillColor)
if (fillType == FillType.fillColor)
{
backgroundColor = DEFAULT_COLOR;
ForegroundColor = value;
Expand Down Expand Up @@ -1171,11 +1171,10 @@ public static void ValidateColor(string hexCode, bool useAlpha, bool allowEmpty
}
throw new StyleException("A general style exception occurred", "The color expression was null or empty");
}
int length;
length = useAlpha ? 8 : 6;
if (hexCode == null || hexCode.Length != length)
int length = useAlpha ? 8 : 6;
if (hexCode.Length != length)
{
throw new StyleException("A general style exception occurred", "The value '" + hexCode + "' is invalid. A valid value must contain six hex characters");
throw new StyleException("A general style exception occurred", "The value '" + hexCode + "' is invalid. A valid value must contain " + length + " hex characters");
}
if (!Regex.IsMatch(hexCode, "[a-fA-F0-9]{6,8}"))
{
Expand Down
6 changes: 3 additions & 3 deletions PicoXLSX/Workbook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -983,11 +983,11 @@ public void Up()
/// Moves the cursor the number of defined rows up
/// </summary>
/// <param name="numberOfRows">Number of rows to move.</param>
/// <param name="keepColumnosition">If true, the column position is preserved, otherwise set to 0.</param>
public void Up(int numberOfRows, bool keepColumnosition = false)
/// <param name="keepColumnPosition">If true, the column position is preserved, otherwise set to 0.</param>
public void Up(int numberOfRows, bool keepColumnPosition = false)
{
NullCheck();
currentWorksheet.GoToNextRow(-1 * numberOfRows, keepColumnosition);
currentWorksheet.GoToNextRow(-1 * numberOfRows, keepColumnPosition);
}

/// <summary>
Expand Down
27 changes: 14 additions & 13 deletions PicoXLSX/Worksheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1890,10 +1890,7 @@ public void SetSelectedCells(string range)
selectedCells.Clear();
return;
}
else
{
SetSelectedCells(new Range(range));
}
SetSelectedCells(new Range(range));
}

/// <summary>
Expand Down Expand Up @@ -2084,11 +2081,13 @@ public void SetVerticalSplit(int numberOfColumnsFromLeft, bool freeze, Cell.Addr
/// <summary>
/// Sets the horizontal and vertical split of the worksheet into four panes. The measurement in rows and columns can be used to split and freeze panes
/// </summary>
/// <param name="numberOfColumnsFromLeft">The numberOfColumnsFromLeft<see cref="int?"/>.</param>
/// <param name="numberOfRowsFromTop">The numberOfRowsFromTop<see cref="int?"/>.</param>
/// <param name="freeze">If true, all panes are frozen, otherwise remains movable.</param>
/// <param name="topLeftCell">Top Left cell address of the bottom right pane (if applicable).</param>
/// <param name="activePane">Active pane in the split window.</param>
/// <param name="numberOfColumnsFromLeft">Number of columns from left of the worksheet to the split line. The particular column widths are considered.<br/>
/// The parameter is nullable. If left null, the method acts identical to <see cref="SetHorizontalSplit(int, bool, Address, WorksheetPane)"/></param>
/// <param name="numberOfRowsFromTop">Number of rows from top of the worksheet to the split line. The particular row heights are considered.<br/>
/// The parameter is nullable. If left null, the method acts identical to <see cref="SetVerticalSplit(int, bool, Address, WorksheetPane)"/></param>
/// <param name="freeze">If true, all panes are frozen, otherwise remains movable</param>
/// <param name="topLeftCell">Top Left cell address of the bottom right pane (if applicable)</param>
/// <param name="activePane">Active pane in the split window.<br/>The parameter is nullable</param>
public void SetSplit(int? numberOfColumnsFromLeft, int? numberOfRowsFromTop, bool freeze, Cell.Address topLeftCell, WorksheetPane activePane)
{
if (freeze)
Expand Down Expand Up @@ -2117,10 +2116,12 @@ public void SetSplit(int? numberOfColumnsFromLeft, int? numberOfRowsFromTop, boo
/// <summary>
/// Sets the horizontal and vertical split of the worksheet into four panes. The measurement in characters cannot be used to freeze panes
/// </summary>
/// <param name="leftPaneWidth">The leftPaneWidth<see cref="float?"/>.</param>
/// <param name="topPaneHeight">The topPaneHeight<see cref="float?"/>.</param>
/// <param name="topLeftCell">Top Left cell address of the bottom right pane (if applicable).</param>
/// <param name="activePane">Active pane in the split window.</param>
/// <param name="leftPaneWidth">Width (similar to column width) from left of the worksheet to the split line in characters.<br/>
/// The parameter is nullable. If left null, the method acts identical to <see cref="SetHorizontalSplit(float, Address, WorksheetPane)"/></param>
/// <param name="topPaneHeight">Height (similar to row height) from top of the worksheet to the split line in characters.<br/>
/// The parameter is nullable. If left null, the method acts identical to <see cref="SetVerticalSplit(float, Address, WorksheetPane)"/></param>
/// <param name="topLeftCell">Top Left cell address of the bottom right pane (if applicable)</param>
/// <param name="activePane">Active pane in the split window.<br/>The parameter is nullable</param>
public void SetSplit(float? leftPaneWidth, float? topPaneHeight, Cell.Address topLeftCell, WorksheetPane activePane)
{
this.paneSplitLeftWidth = leftPaneWidth;
Expand Down

0 comments on commit d84bd82

Please sign in to comment.