2023-04-06 08:29:39 +03:00
|
|
|
|
#if !NET472
|
|
|
|
|
using System.Runtime.Versioning;
|
|
|
|
|
#endif
|
2023-04-01 15:24:04 +03:00
|
|
|
|
|
2023-04-06 16:40:00 +03:00
|
|
|
|
namespace RhSolutions.Tools;
|
2022-02-04 17:13:47 +03:00
|
|
|
|
|
2023-04-06 08:29:39 +03:00
|
|
|
|
#if !NET472
|
|
|
|
|
[SupportedOSPlatform("windows")]
|
|
|
|
|
#endif
|
2023-03-28 10:36:36 +03:00
|
|
|
|
public static class WorksheetExtensions
|
2022-02-04 17:13:47 +03:00
|
|
|
|
{
|
2023-04-06 21:37:21 +03:00
|
|
|
|
private static readonly Dictionary<string, string> pricelistParameters =
|
|
|
|
|
RhSolutionsAddIn.Configuration.GetPriceListHeaders();
|
|
|
|
|
|
2023-04-06 08:49:12 +03:00
|
|
|
|
public static bool IsValidSource(this Worksheet worksheet)
|
2022-02-04 17:13:47 +03:00
|
|
|
|
{
|
2023-03-28 10:36:36 +03:00
|
|
|
|
Range amountCell;
|
|
|
|
|
Range skuCell;
|
2023-04-06 08:29:39 +03:00
|
|
|
|
Range programLineCell;
|
2023-03-28 10:36:36 +03:00
|
|
|
|
Range nameCell;
|
2023-05-05 08:21:26 +03:00
|
|
|
|
Range measureCell;
|
2023-03-28 10:36:36 +03:00
|
|
|
|
|
|
|
|
|
Range[] cells = new[]
|
2022-02-04 17:13:47 +03:00
|
|
|
|
{
|
2023-04-01 15:24:04 +03:00
|
|
|
|
amountCell = worksheet.Cells.Find(pricelistParameters["Amount"]),
|
|
|
|
|
skuCell = worksheet.Cells.Find(pricelistParameters["Sku"]),
|
2023-04-06 08:29:39 +03:00
|
|
|
|
programLineCell = worksheet.Cells.Find(pricelistParameters["ProductLine"]),
|
2023-05-05 08:21:26 +03:00
|
|
|
|
nameCell = worksheet.Cells.Find(pricelistParameters["Name"]),
|
|
|
|
|
measureCell = worksheet.Cells.Find(pricelistParameters["Measure"])
|
2023-03-28 10:36:36 +03:00
|
|
|
|
};
|
2022-02-04 17:13:47 +03:00
|
|
|
|
|
2023-03-28 10:36:36 +03:00
|
|
|
|
return cells.All(x => x != null);
|
|
|
|
|
}
|
2022-02-04 17:13:47 +03:00
|
|
|
|
|
2023-03-28 10:36:36 +03:00
|
|
|
|
public static void AddValue(this Range range, double value)
|
|
|
|
|
{
|
|
|
|
|
if (range.Value2 == null)
|
|
|
|
|
{
|
|
|
|
|
range.Value2 = value;
|
2022-02-04 17:13:47 +03:00
|
|
|
|
}
|
2022-02-08 16:19:49 +03:00
|
|
|
|
|
2023-03-28 10:36:36 +03:00
|
|
|
|
else
|
2022-02-08 16:19:49 +03:00
|
|
|
|
{
|
2023-03-28 10:36:36 +03:00
|
|
|
|
range.Value2 += value;
|
2022-02-08 16:19:49 +03:00
|
|
|
|
}
|
2022-02-04 17:13:47 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|