Quantcast
Channel: EPPlus Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 2262

Commented Unassigned: GetTypedValue Nullable Conversion [15377]

$
0
0
ExcelWorksheet.GetValue<T> throws an exception when passed double?.

In ExcelWorksheet.cs, Line 2603 throws an exception when trying to convert a nullable type (e.g. double?): "'DoubleConverter' is unable to convert 'System.Double' to 'System.Nullable`1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'".

Changing the line from
```
return (T)cnv.ConvertTo(v, typeof(T));
```

to

```
return (T)cnv.ConvertTo(v, toType);
```

fixes this issue. This works because line 2600 is changing 'toType' to the underlying type of the nullable (see below).

```
toType = Nullable.GetUnderlyingType(toType);
if (cnv.CanConvertTo(toType))
{
return (T)cnv.ConvertTo(v, toType);
}
```
Comments: Fixed in changeset 31e4b2540087

Viewing all articles
Browse latest Browse all 2262

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>