diff --git a/samples/xlsx/TestIssue409.xlsx b/samples/xlsx/TestIssue409.xlsx new file mode 100644 index 00000000..9361134e Binary files /dev/null and b/samples/xlsx/TestIssue409.xlsx differ diff --git a/samples/xlsx/TestIssue881.xlsx b/samples/xlsx/TestIssue881.xlsx new file mode 100644 index 00000000..7cc784bb Binary files /dev/null and b/samples/xlsx/TestIssue881.xlsx differ diff --git a/src/MiniExcel/Utils/TypeHelper.cs b/src/MiniExcel/Utils/TypeHelper.cs index f1e30aed..da802441 100644 --- a/src/MiniExcel/Utils/TypeHelper.cs +++ b/src/MiniExcel/Utils/TypeHelper.cs @@ -199,8 +199,17 @@ public static bool IsNumericType(Type type, bool isNullableUnderlyingType = fals } else if (pInfo.ExcludeNullableType == typeof(double)) // && (!Regex.IsMatch(itemValue.ToString(), @"^-?\d+(\.\d+)?([eE][-+]?\d+)?$") || itemValue.ToString().Trim().Equals("NaN"))) { - var invariantString = Convert.ToString(itemValue, CultureInfo.InvariantCulture); - newValue = double.TryParse(invariantString, NumberStyles.Any, CultureInfo.InvariantCulture, out var value) ? value : double.NaN; + if (double.TryParse(Convert.ToString(itemValue, config.Culture), NumberStyles.Any, config.Culture, out var doubleValue)) + { + newValue = doubleValue; + } + else + { + var invariantString = Convert.ToString(itemValue, CultureInfo.InvariantCulture); + newValue = double.TryParse(invariantString, NumberStyles.Any, CultureInfo.InvariantCulture, out var value) + ? value + : throw new InvalidCastException($"Value \"{itemValue}\" cannot be cast to double"); + } } else if (pInfo.ExcludeNullableType == typeof(bool)) {