Skip to content

Commit

Permalink
add nullable type support (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaguangli authored Jun 10, 2024
1 parent 0c878b1 commit 12bb1c0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/MiniExcel/Utils/TypeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,15 @@ public static bool IsNumericType(Type type, bool isNullableUnderlyingType = fals
}
else
{
// Use pInfo.ExcludeNullableType to resolve : https://github.com/shps951023/MiniExcel/issues/138
newValue = Convert.ChangeType(itemValue, pInfo.ExcludeNullableType, _config.Culture);
if (pInfo.Nullable && string.IsNullOrWhiteSpace(itemValue?.ToString()))
{
newValue = null;
}
else
{
// Use pInfo.ExcludeNullableType to resolve : https://github.com/shps951023/MiniExcel/issues/138
newValue = Convert.ChangeType(itemValue, pInfo.ExcludeNullableType, _config.Culture);
}
}

pInfo.Property.SetValue(v, newValue);
Expand Down

0 comments on commit 12bb1c0

Please sign in to comment.