diff --git a/ClosedXML/Excel/Cells/XLCell.cs b/ClosedXML/Excel/Cells/XLCell.cs index 4eff7e8..7a131ed 100644 --- a/ClosedXML/Excel/Cells/XLCell.cs +++ b/ClosedXML/Excel/Cells/XLCell.cs @@ -233,14 +233,14 @@ _cellValue = value.ToString(); _dataType = XLCellValues.TimeSpan; if (style.NumberFormat.Format == String.Empty && style.NumberFormat.NumberFormatId == 0) - Style.NumberFormat.NumberFormatId = 46; + Style.NumberFormat.NumberFormatId = 46; } else if (value is DateTime) { _dataType = XLCellValues.DateTime; var dtTest = (DateTime)Convert.ChangeType(value, typeof(DateTime)); if (style.NumberFormat.Format == String.Empty && style.NumberFormat.NumberFormatId == 0) - Style.NumberFormat.NumberFormatId = dtTest.Date == dtTest ? 14 : 22; + Style.NumberFormat.NumberFormatId = dtTest.Date == dtTest ? 14 : 22; _cellValue = dtTest.ToOADate().ToInvariantString(); } @@ -480,7 +480,7 @@ if (!data.Any()) { - if (itemType.IsPrimitive || itemType == typeof(String) || itemType == typeof (DateTime) || itemType.IsNumber()) + if (itemType.IsPrimitive || itemType == typeof(String) || itemType == typeof(DateTime) || itemType.IsNumber()) maxCo = Address.ColumnNumber + 1; else maxCo = Address.ColumnNumber + itemType.GetFields().Length + itemType.GetProperties().Length; diff --git a/ClosedXML/Extensions.cs b/ClosedXML/Extensions.cs index 18518d9..67db6c4 100644 --- a/ClosedXML/Extensions.cs +++ b/ClosedXML/Extensions.cs @@ -1,30 +1,28 @@ -using System; -using System.Collections; +using ClosedXML.Utils; +using DocumentFormat.OpenXml; +using System; using System.Collections.Generic; using System.Drawing; using System.Globalization; +using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; -using System.Xml.Linq; -using System.IO; using System.Xml; -using ClosedXML.Utils; -using DocumentFormat.OpenXml; +using System.Xml.Linq; [assembly: CLSCompliantAttribute(true)] + namespace ClosedXML.Excel { public static class Extensions { // Adds the .ForEach method to all IEnumerables - - private static readonly char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + private static readonly char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; public static String ToHex(this Color color) { - byte[] bytes = new byte[4]; bytes[0] = color.A; @@ -39,17 +37,14 @@ for (int i = 0; i < bytes.Length; i++) { - int b = bytes[i]; chars[i * 2] = hexDigits[b >> 4]; chars[i * 2 + 1] = hexDigits[b & 0xF]; - } return new string(chars); - } public static String RemoveSpecialCharacters(this String str) @@ -75,10 +70,10 @@ HashSet distinctItems = new HashSet(); foreach (var item in source) { - if (!distinctItems.Add(item)) - { - return true; - } + if (!distinctItems.Add(item)) + { + return true; + } } return false; } @@ -87,7 +82,6 @@ { return (T)Convert.ChangeType(o, typeof(T)); } - } public static class DictionaryExtensions @@ -106,6 +100,7 @@ public static class StringExtensions { private static readonly Regex RegexNewLine = new Regex(@"((? intToString; + public static String ToInvariantString(this Int32 value) { String sValue; @@ -200,7 +196,6 @@ } return sValue; } - } public static class DecimalExtensions @@ -233,7 +228,6 @@ public static class FontBaseExtensions { - private static Font GetCachedFont(IXLFontBase fontBase, Dictionary fontCache) { Font font; @@ -266,7 +260,7 @@ if (font.Bold) fontStyle |= FontStyle.Bold; if (font.Italic) fontStyle |= FontStyle.Italic; if (font.Strikethrough) fontStyle |= FontStyle.Strikeout; - if (font.Underline != XLFontUnderlineValues.None ) fontStyle |= FontStyle.Underline; + if (font.Underline != XLFontUnderlineValues.None) fontStyle |= FontStyle.Underline; return fontStyle; } @@ -360,5 +354,4 @@ || type == typeof(decimal); } } -} - +} \ No newline at end of file