62 lines
1.5 KiB
C#
62 lines
1.5 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 measureCell;
|
|
|
|
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"]),
|
|
measureCell = worksheet.Cells.Find(pricelistParameters["Measure"])
|
|
};
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
public static void AddValue(this Range range, string value)
|
|
{
|
|
if (range.Value2 == null)
|
|
{
|
|
range.Value2 = value;
|
|
}
|
|
|
|
else
|
|
{
|
|
range.Value2 = $"{range.Value2} {value}";
|
|
}
|
|
}
|
|
}
|
|
|