Compare commits

...

2 Commits

Author SHA1 Message Date
Sergey Chebotar
1c655f1ab5 Version 1.8.1.0 2023-05-26 07:50:45 +03:00
Sergey Chebotar
1220999bf0 Fix row indeces 2023-05-26 07:50:23 +03:00
2 changed files with 8 additions and 9 deletions

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.8.0.0")] [assembly: AssemblyVersion("1.8.1.0")]
[assembly: AssemblyFileVersion("1.8.0.0")] [assembly: AssemblyFileVersion("1.8.1.0")]

View File

@ -149,19 +149,18 @@ public class GuessReader : IReader
private Dictionary<Product, double> GetDictionaryFromColumns(Range productColumn, Range amountColumn) private Dictionary<Product, double> GetDictionaryFromColumns(Range productColumn, Range amountColumn)
{ {
Dictionary<Product, double> result = new(); Dictionary<Product, double> result = new();
var firstRowIndex = 1;
var lastRowIndex = amountColumn.Worksheet var lastRowIndex = amountColumn.Worksheet
.Cells[amountColumn.Rows.Count, amountColumn.Column] .Cells[amountColumn.Worksheet.Rows.Count, amountColumn.Column]
.End[XlDirection.xlUp].Row; .End[XlDirection.xlUp].Row;
_progressBar = new("Заполняю словарь значений...", lastRowIndex); _progressBar = new("Заполняю словарь значений...", lastRowIndex);
Worksheet worksheet = amountColumn.Worksheet;
for (int row = 1; row < lastRowIndex + 1; row++) for (int row = firstRowIndex; row < lastRowIndex + 1; row++)
{ {
_progressBar.Update(); _progressBar.Update();
var amountCells = amountColumn.Value2; object currentAmountCell = worksheet.Cells[row, amountColumn.Column].Value2;
object currentAmountCell = productColumn.Rows.Count == 1 ? amountCells : amountCells[row, 1]; object currentProductCell = worksheet.Cells[row, productColumn.Column].Value2;
var productCells = productColumn.Value2;
object currentProductCell = productColumn.Rows.Count == 1 ? productCells : productCells[row, 1];
double? amountValue = currentAmountCell as double?; double? amountValue = currentAmountCell as double?;
if (amountValue == null || amountValue == 0 || currentProductCell == null) if (amountValue == null || amountValue == 0 || currentProductCell == null)