RhSolutions-AddIn/RhSolutions.AddIn/Tools/WorksheetExtensions.cs
2023-04-06 21:37:21 +03:00

47 lines
1.1 KiB
C#

#if !NET472
using System.Runtime.Versioning;
#endif
namespace RhSolutions.Tools;
#if !NET472
[SupportedOSPlatform("windows")]
#endif
public static class WorksheetExtensions
{
private static readonly Dictionary<string, string> pricelistParameters =
RhSolutionsAddIn.Configuration.GetPriceListHeaders();
public static bool IsValidSource(this Worksheet worksheet)
{
Range amountCell;
Range skuCell;
Range programLineCell;
Range nameCell;
Range[] cells = new[]
{
amountCell = worksheet.Cells.Find(pricelistParameters["Amount"]),
skuCell = worksheet.Cells.Find(pricelistParameters["Sku"]),
programLineCell = worksheet.Cells.Find(pricelistParameters["ProductLine"]),
nameCell = worksheet.Cells.Find(pricelistParameters["Name"])
};
return cells.All(x => x != null);
}
public static void AddValue(this Range range, double value)
{
if (range.Value2 == null)
{
range.Value2 = value;
}
else
{
range.Value2 += value;
}
}
}