#if !NET472 using System.Runtime.Versioning; #endif namespace RhSolutions.Tools; #if !NET472 [SupportedOSPlatform("windows")] #endif public static class WorksheetExtensions { private static readonly Dictionary 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; } } }