diff --git a/ENI2/Excel/ExcelReader.cs b/ENI2/Excel/ExcelReader.cs index 923df818..8a5c8edf 100644 --- a/ENI2/Excel/ExcelReader.cs +++ b/ENI2/Excel/ExcelReader.cs @@ -475,7 +475,7 @@ namespace ENI2.Excel if (DateTime.TryParseExact(dateString, format, provider, DateTimeStyles.None, out DateTime tmpDate)) date = tmpDate; } - } + } else if (cellValue.IsText) { string textValue = cellValue.GetText(); @@ -562,6 +562,11 @@ namespace ENI2.Excel { result = cellValue.GetDateTime(); } + else if (cellValue.IsTimeSpan) + { + TimeSpan timespan = cellValue.GetTimeSpan(); + result = new DateTime(timespan.Ticks); + } else if (cellValue.IsNumber) { double numValue = 0; @@ -774,7 +779,7 @@ namespace ENI2.Excel string dateString = ReadCellAsText(sheetName, range); if (dateString != null) { - string[] formats = { "yyyy/MM/dd HH:mm", "yyyy/MM/dd", "dd.MM.yyyy", "dd-MM-yyyy", "d/M/yyyy", "dd/M/yyyy", "d/MM/yyyy", "dd/MM/yyyy", "d/MMM/yyyy", "dd/MMM/yyyy", "yyyy-MM-dd", "yyyy-mm-d" }; + string[] formats = { "yyyy/MM/dd HH:mm", "yyyy/MM/dd", "dd.MM.yyyy", "dd-MM-yyyy", "d/M/yyyy", "dd/M/yyyy", "d/MM/yyyy", "dd/MM/yyyy", "d/MMM/yyyy", "dd/MMM/yyyy", "yyyy-MM-dd", "yyyy-MM-d", "dd.MM.yyyy HH:mm:ss", "dd.MM.yyyy HH:mm" }; if (DateTime.TryParseExact(dateString, formats, NumberFormatInfo.InvariantInfo, DateTimeStyles.None, out DateTime tmpDate)) return tmpDate; CultureInfo en = CultureInfo.CreateSpecificCulture("en-US"); diff --git a/ENI2/Excel/ExcelUtil.cs b/ENI2/Excel/ExcelUtil.cs index 003f25e7..99c4c2ea 100644 --- a/ENI2/Excel/ExcelUtil.cs +++ b/ENI2/Excel/ExcelUtil.cs @@ -1702,7 +1702,7 @@ namespace ENI2.Excel string s = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", 54 + i)); // All invalid codes become "0000", Oct/25 - l10fc.PortFacilityGISISCode = (s != null) && Regex.IsMatch(s.Trim(), @"^\d{4}$") ? s.Trim() : "0000"; + l10fc.PortFacilityGISISCode = (s != null) && Regex.IsMatch(s.Trim(), @"^\d{1,4}$") ? s.Trim().PadLeft(4, '0') : "0000"; l10fc.PortFacilitySecurityMattersToReport = reader.ReadCellAsText(sheetTitle, string.Format("K{0}", 54 + i), 255);