Compare commits
5 Commits
8902d51c14
...
d6a78c42c7
Author | SHA1 | Date | |
---|---|---|---|
|
d6a78c42c7 | ||
|
08fcc33f9d | ||
|
f9ff1e55b9 | ||
|
ea69a77a0e | ||
|
28d6c3b6b9 |
@ -8,6 +8,7 @@
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
|
||||
<ExcelDnaPackCompressResources>false</ExcelDnaPackCompressResources>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
|
@ -4,6 +4,8 @@ using RhSolutions.Tools;
|
||||
#endif
|
||||
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace RhSolutions.Services;
|
||||
|
||||
#if !NET472
|
||||
@ -130,6 +132,12 @@ public class ExcelWriter : IWriter, IDisposable
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
Range nameCell = worksheetCells[row, _nameCell.Column];
|
||||
if (!Regex.IsMatch(nameCell.Value2, @"(арт. \d{11})"))
|
||||
{
|
||||
nameCell.AddValue($"-> замена (арт. {positionAmount.Key.ProductSku})");
|
||||
}
|
||||
|
||||
foreach (int column in columns)
|
||||
{
|
||||
Range cell = worksheetCells[row, column];
|
||||
@ -146,6 +154,12 @@ public class ExcelWriter : IWriter, IDisposable
|
||||
|
||||
if (row != null)
|
||||
{
|
||||
Range nameCell = worksheetCells[row, _nameCell.Column];
|
||||
if (!Regex.IsMatch(nameCell.Value2, @"(арт. \d{11})"))
|
||||
{
|
||||
nameCell.AddValue($" -> замена (арт. {positionAmount.Key.ProductSku})");
|
||||
}
|
||||
|
||||
foreach (int column in columns)
|
||||
{
|
||||
Range cell = worksheetCells[row, column];
|
||||
@ -184,8 +198,7 @@ public class ExcelWriter : IWriter, IDisposable
|
||||
current.ClearContents();
|
||||
|
||||
worksheetCells[row, groupColumn].Value2 = product.ProductLines.FirstOrDefault() ?? string.Empty;
|
||||
worksheetCells[row, nameColumn].Value2 = $"{product.Name} не найден ({product.ProductSku})";
|
||||
|
||||
worksheetCells[row, nameColumn].Value2 = $"{product.Name} -> не найден (арт. {product.ProductSku})";
|
||||
worksheetCells[row, skuColumn].Value2 = "???";
|
||||
if (_oldSkuCell != null)
|
||||
{
|
||||
|
@ -44,5 +44,18 @@ public static class WorksheetExtensions
|
||||
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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,14 +45,14 @@ public class CanReadProducts : IDisposable
|
||||
Assert.Equal(3, products.Count());
|
||||
}
|
||||
|
||||
[ExcelFact(Workbook = @"TestWorkbooks\TestSpecificaion.xlsx")]
|
||||
[ExcelFact(Workbook = @"TestWorkbooks\TestSpecification.xlsx")]
|
||||
public void CanReadWorkbook()
|
||||
{
|
||||
Worksheet worksheet = Util.Workbook.Worksheets[1];
|
||||
var result = _reader.ReadProducts(new[] { worksheet });
|
||||
Assert.NotNull(result);
|
||||
Assert.NotEmpty(result);
|
||||
Assert.Equal("TestSpecificaion", result.First().Item1);
|
||||
Assert.Equal("TestSpecification", result.First().Item1);
|
||||
var products = result.First().Item2;
|
||||
Assert.Equal(46, products.Count());
|
||||
Assert.Equal(29266, products.Sum(p => p.Value));
|
||||
|
Loading…
x
Reference in New Issue
Block a user