49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
#if !NET472
|
|
using System.Runtime.Versioning;
|
|
using RhSolutions;
|
|
using RhSolutions.Services;
|
|
using RhSolutions.Tools;
|
|
#endif
|
|
|
|
namespace RhSolutions.Tools;
|
|
|
|
#if !NET472
|
|
[SupportedOSPlatform("windows")]
|
|
#endif
|
|
public static class WorksheetExtensions
|
|
{
|
|
public static bool IsValidSource(this Worksheet worksheet)
|
|
{
|
|
Range amountCell;
|
|
Range skuCell;
|
|
Range programLineCell;
|
|
Range nameCell;
|
|
|
|
var pricelistParameters = RhSolutionsAddIn.Configuration.GetPriceListHeaders();
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|