diff --git a/Changelog.md b/Changelog.md index c41a6b94..a4725918 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 --- diff --git a/Demo .NET Standard/Demo .NET Standard.csproj b/Demo .NET Standard/Demo .NET Standard.csproj index 98f8db48..9b739edf 100644 --- a/Demo .NET Standard/Demo .NET Standard.csproj +++ b/Demo .NET Standard/Demo .NET Standard.csproj @@ -5,12 +5,12 @@ net5.0 PicoXLSX PicoXLSX.Demo - Copyright Raphael Stoeckli © 2022 + Copyright Raphael Stoeckli © 2023 https://github.com/rabanti-github/PicoXLSX.git https://github.com/rabanti-github/PicoXLSX - 3.1.0.0 - 3.1.0.0 - 3.1.0 + 3.1.1.0 + 3.1.1.0 + 3.1.1 Demo Library showing the use of PicoXLSX, a library to generate Microsoft Excel files (XLSX) in an easy and native way Demo.Program MIT diff --git a/Demo/Program.cs b/Demo/Program.cs index aa982156..a9f088e2 100644 --- a/Demo/Program.cs +++ b/Demo/Program.cs @@ -13,7 +13,7 @@ namespace Demo { - class Program + static class Program { /// /// Method to run all demos / testing scenarios (currently disabled) diff --git a/Demo/Properties/AssemblyInfo.cs b/Demo/Properties/AssemblyInfo.cs index 5742596b..a87f0e94 100644 --- a/Demo/Properties/AssemblyInfo.cs +++ b/Demo/Properties/AssemblyInfo.cs @@ -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")] diff --git a/Demo/Testing/Performance.cs b/Demo/Testing/Performance.cs index 553e0087..67d69096 100644 --- a/Demo/Testing/Performance.cs +++ b/Demo/Testing/Performance.cs @@ -18,24 +18,24 @@ namespace Demo.Testing /// /// Class for performance tests /// - public class Performance + public static class Performance { /// /// Method to perform a stress test on PicoXLSX with a high amount of random data /// /// filename of the output - /// name of the worksheet + /// name of the worksheet /// Number of rows /// Number of columns /// 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 - 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> field = new List>(); List row; List colTypes = new List(); - 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++) { @@ -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++) diff --git a/Demo/Testing/TypeTesting.cs b/Demo/Testing/TypeTesting.cs index e3b5de4c..8e3edc6c 100644 --- a/Demo/Testing/TypeTesting.cs +++ b/Demo/Testing/TypeTesting.cs @@ -17,7 +17,7 @@ namespace Demo.Testing /// /// Class for testing of several data types /// - public class TypeTesting + public static class TypeTesting { public static void NumericTypeTesting(string fileName) diff --git a/PicoXLSX .NET Standard/PicoXLSX .NET Standard.csproj b/PicoXLSX .NET Standard/PicoXLSX .NET Standard.csproj index bdcbbe6a..ed62eccb 100644 --- a/PicoXLSX .NET Standard/PicoXLSX .NET Standard.csproj +++ b/PicoXLSX .NET Standard/PicoXLSX .NET Standard.csproj @@ -4,12 +4,12 @@ netstandard2.0;net45 PicoXLSX PicoXLSX - 3.1.0 + 3.1.1 Raphael Stoeckli PicoXLSX PicoXLSX is a library to generate Microsoft Excel files (XLSX) in an easy and native way - Copyright Raphael Stoeckli © 2022 + Copyright Raphael Stoeckli © 2023 MIT https://github.com/rabanti-github/PicoXLSX PicoXLSX.png @@ -17,8 +17,8 @@ Excel Office XLSX Please see https://github.com/rabanti-github/PicoXLSX/blob/master/Changelog.md for the release notes true - 3.1.0.0 - 3.1.0.0 + 3.1.1.0 + 3.1.1.0 PicoXLSX favicon.ico diff --git a/PicoXLSX/Cell.cs b/PicoXLSX/Cell.cs index a8ae5571..4066d504 100644 --- a/PicoXLSX/Cell.cs +++ b/PicoXLSX/Cell.cs @@ -736,7 +736,7 @@ public struct Address : IEquatable
, IComparable
public AddressType Type; /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// /// Column number (zero based). /// Row number (zero based). @@ -749,7 +749,7 @@ public Address(int column, int row, AddressType type = AddressType.Default) } /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// /// Address string (e.g. 'A1:B12'). /// Optional referencing type of the address. @@ -869,7 +869,7 @@ public struct Range public Address StartAddress; /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// /// Start address of the range. /// End address of the range. @@ -888,7 +888,7 @@ public Range(Address start, Address end) } /// - /// Initializes a new instance of the class + /// Initializes a new instance of the class /// /// Address range (e.g. 'A1:B12'). public Range(string range) diff --git a/PicoXLSX/LowLevel.cs b/PicoXLSX/LowLevel.cs index 75ab4170..2fa65661 100644 --- a/PicoXLSX/LowLevel.cs +++ b/PicoXLSX/LowLevel.cs @@ -60,19 +60,19 @@ internal class LowLevel /// /// First date that can be displayed by Excel. Real values before this date cannot be processed. /// - 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); /// /// All dates before this date are shifted in Excel by -1.0, since Excel assumes wrongly that the year 1900 is a leap year.
/// See also: /// https://docs.microsoft.com/en-us/office/troubleshoot/excel/wrongly-assumes-1900-is-leap-year ///
- 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); /// /// Last date that can be displayed by Excel. Real values after this date cannot be processed. /// - 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); /// /// Constant for number conversion. The invariant culture (represents mostly the US numbering scheme) ensures that no culture-specific @@ -125,7 +125,7 @@ internal class LowLevel /// /// Defines the ROOT_MILLIS /// - 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; /// /// Defines the culture @@ -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); @@ -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); } @@ -1791,12 +1788,12 @@ public static float GetInternalPaneSplitHeight(float height) /// /// Class representing a row that is either empty or containing cells. Empty rows can also carry information about height or visibility /// - private class DynamicRow + private sealed class DynamicRow { /// /// Defines the cellDefinitions /// - private List cellDefinitions; + private readonly List cellDefinitions; /// /// Gets or sets the row number (zero-based) diff --git a/PicoXLSX/Properties/AssemblyInfo.cs b/PicoXLSX/Properties/AssemblyInfo.cs index a07ec4ec..cc3317c8 100644 --- a/PicoXLSX/Properties/AssemblyInfo.cs +++ b/PicoXLSX/Properties/AssemblyInfo.cs @@ -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")] diff --git a/PicoXLSX/Style.cs b/PicoXLSX/Style.cs index c1f6fbc6..0dd88718 100644 --- a/PicoXLSX/Style.cs +++ b/PicoXLSX/Style.cs @@ -1026,10 +1026,10 @@ public Fill(string foreground, string background) /// Initializes a new instance of the class /// /// Color value. - /// Fill type (fill or pattern). - public Fill(string value, FillType filltype) + /// Fill type (fill or pattern). + public Fill(string value, FillType fillType) { - if (filltype == FillType.fillColor) + if (fillType == FillType.fillColor) { backgroundColor = DEFAULT_COLOR; ForegroundColor = value; @@ -1101,10 +1101,10 @@ public Fill CopyFill() /// Sets the color and the depending fill type /// /// color value. - /// fill type (fill or pattern). - public void SetColor(string value, FillType filltype) + /// fill type (fill or pattern). + public void SetColor(string value, FillType fillType) { - if (filltype == FillType.fillColor) + if (fillType == FillType.fillColor) { backgroundColor = DEFAULT_COLOR; ForegroundColor = value; @@ -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}")) { diff --git a/PicoXLSX/Workbook.cs b/PicoXLSX/Workbook.cs index a0087207..45e1f9bf 100644 --- a/PicoXLSX/Workbook.cs +++ b/PicoXLSX/Workbook.cs @@ -983,11 +983,11 @@ public void Up() /// Moves the cursor the number of defined rows up /// /// Number of rows to move. - /// If true, the column position is preserved, otherwise set to 0. - public void Up(int numberOfRows, bool keepColumnosition = false) + /// If true, the column position is preserved, otherwise set to 0. + public void Up(int numberOfRows, bool keepColumnPosition = false) { NullCheck(); - currentWorksheet.GoToNextRow(-1 * numberOfRows, keepColumnosition); + currentWorksheet.GoToNextRow(-1 * numberOfRows, keepColumnPosition); } /// diff --git a/PicoXLSX/Worksheet.cs b/PicoXLSX/Worksheet.cs index e9f33c84..ad44b451 100644 --- a/PicoXLSX/Worksheet.cs +++ b/PicoXLSX/Worksheet.cs @@ -1890,10 +1890,7 @@ public void SetSelectedCells(string range) selectedCells.Clear(); return; } - else - { - SetSelectedCells(new Range(range)); - } + SetSelectedCells(new Range(range)); } /// @@ -2084,11 +2081,13 @@ public void SetVerticalSplit(int numberOfColumnsFromLeft, bool freeze, Cell.Addr /// /// 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 /// - /// The numberOfColumnsFromLeft. - /// The numberOfRowsFromTop. - /// If true, all panes are frozen, otherwise remains movable. - /// Top Left cell address of the bottom right pane (if applicable). - /// Active pane in the split window. + /// Number of columns from left of the worksheet to the split line. The particular column widths are considered.
+ /// The parameter is nullable. If left null, the method acts identical to + /// Number of rows from top of the worksheet to the split line. The particular row heights are considered.
+ /// The parameter is nullable. If left null, the method acts identical to + /// If true, all panes are frozen, otherwise remains movable + /// Top Left cell address of the bottom right pane (if applicable) + /// Active pane in the split window.
The parameter is nullable public void SetSplit(int? numberOfColumnsFromLeft, int? numberOfRowsFromTop, bool freeze, Cell.Address topLeftCell, WorksheetPane activePane) { if (freeze) @@ -2117,10 +2116,12 @@ public void SetSplit(int? numberOfColumnsFromLeft, int? numberOfRowsFromTop, boo /// /// Sets the horizontal and vertical split of the worksheet into four panes. The measurement in characters cannot be used to freeze panes /// - /// The leftPaneWidth. - /// The topPaneHeight. - /// Top Left cell address of the bottom right pane (if applicable). - /// Active pane in the split window. + /// Width (similar to column width) from left of the worksheet to the split line in characters.
+ /// The parameter is nullable. If left null, the method acts identical to + /// Height (similar to row height) from top of the worksheet to the split line in characters.
+ /// The parameter is nullable. If left null, the method acts identical to + /// Top Left cell address of the bottom right pane (if applicable) + /// Active pane in the split window.
The parameter is nullable public void SetSplit(float? leftPaneWidth, float? topPaneHeight, Cell.Address topLeftCell, WorksheetPane activePane) { this.paneSplitLeftWidth = leftPaneWidth;