|
@@ -3,9 +3,9 @@ using ClosedXML.Excel;
|
|
|
|
|
|
namespace ExcelORM;
|
|
|
|
|
|
-
|
|
|
public static class TypeExtensions
|
|
|
{
|
|
|
+
|
|
|
private static object? ToObject(this XLCellValue value)
|
|
|
{
|
|
|
return value.Type switch
|
|
@@ -21,6 +21,20 @@ public static class TypeExtensions
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ private static Type ValueType(this XLCellValue value)
|
|
|
+ {
|
|
|
+ return value.Type switch
|
|
|
+ {
|
|
|
+ XLDataType.Blank => typeof(string),
|
|
|
+ XLDataType.Boolean => typeof(bool),
|
|
|
+ XLDataType.Number => typeof(double?),
|
|
|
+ XLDataType.Text => typeof(string),
|
|
|
+ XLDataType.DateTime => typeof(DateTime?),
|
|
|
+ XLDataType.TimeSpan => typeof(TimeSpan?),
|
|
|
+ _ => throw new InvalidCastException()
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
public static void SetPropertyValue<T>(this T currentObject, PropertyInfo property, XLCellValue value)
|
|
|
{
|
|
|
var valueToSet = value.ToObject();
|