forked from ddrilling/AsbCloudServer
Улучшения метода расширения. Добавил возможность возвращать null
This commit is contained in:
parent
0b95361b69
commit
ac578bce38
@ -185,8 +185,7 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
|||||||
AzimuthMagnetic = row.Cell(ColumnAzimuthMagnetic).GetCellValue<double>(),
|
AzimuthMagnetic = row.Cell(ColumnAzimuthMagnetic).GetCellValue<double>(),
|
||||||
VerticalDepth = row.Cell(ColumnVerticalDepth).GetCellValue<double>(),
|
VerticalDepth = row.Cell(ColumnVerticalDepth).GetCellValue<double>(),
|
||||||
Radius = row.Cell(ColumnRadius).GetCellValue<double>(),
|
Radius = row.Cell(ColumnRadius).GetCellValue<double>(),
|
||||||
Comment = row.Cell(ColumnComment).IsEmpty() ? null :
|
Comment = row.Cell(ColumnComment).GetCellValue<string?>()
|
||||||
row.Cell(ColumnComment).GetCellValue<string>()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return trajectoryRow;
|
return trajectoryRow;
|
||||||
|
@ -158,10 +158,13 @@ internal static class XLExtentions
|
|||||||
=> sheet.Range(begin.RowNumber, begin.ColumnNumber, end.RowNumber, end.ColumnNumber);
|
=> sheet.Range(begin.RowNumber, begin.ColumnNumber, end.RowNumber, end.ColumnNumber);
|
||||||
|
|
||||||
|
|
||||||
internal static T GetCellValue<T>(this IXLCell cell)
|
internal static T? GetCellValue<T>(this IXLCell cell)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (cell.IsEmpty() && default(T) == null)
|
||||||
|
return default;
|
||||||
|
|
||||||
if (typeof(T) != typeof(DateTime))
|
if (typeof(T) != typeof(DateTime))
|
||||||
return (T)Convert.ChangeType(cell.GetFormattedString(), typeof(T), CultureInfo.InvariantCulture);
|
return (T)Convert.ChangeType(cell.GetFormattedString(), typeof(T), CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user