Files
OpenNest/OpenNest.IO/Bom/CellExtensions.cs
T
aj aec0523062 style: apply CSharpier formatting to all C# sources
Repo-wide sweep with the pinned CSharpier 1.3.0 tool. Whitespace and
line-wrapping only; OpenNest.Engine.Tests (109) and OpenNest.IO.Tests
pass after reformat, full solution builds 0 errors.

Added .csharpierignore so csproj/config XML keeps its existing layout
(CSharpier's XML wrapping churns attributes with zero benefit).

Formatting is now enforceable: dotnet csharpier check . passes.
2026-09-20 16:41:50 -04:00

30 lines
814 B
C#

using ClosedXML.Excel;
namespace OpenNest.IO.Bom
{
public static class CellExtensions
{
public static int? ToIntOrNull(this IXLCell cell)
{
if (cell.IsEmpty())
return null;
if (cell.DataType == XLDataType.Number)
return (int)cell.GetDouble();
if (int.TryParse(cell.GetString(), out var i))
return i;
return null;
}
public static double? ToDoubleOrNull(this IXLCell cell)
{
if (cell.IsEmpty())
return null;
if (cell.DataType == XLDataType.Number)
return cell.GetDouble();
if (double.TryParse(cell.GetString(), out var result))
return result;
return null;
}
}
}