aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Chebotar <s.chebotar@gmail.com>2023-05-26 07:50:23 +0300
committerSergey Chebotar <s.chebotar@gmail.com>2023-05-26 07:50:23 +0300
commit1220999bf067f630369848ed6135f83df23aa08f (patch)
tree21a216543af7066308c10ad12c228de8c765fdbe
parent1e64511ae10deefdbc02a5240a56849075941d3f (diff)
Fix row indeces
-rw-r--r--RhSolutions.AddIn/Services/GuessReader.cs13
1 files changed, 6 insertions, 7 deletions
diff --git a/RhSolutions.AddIn/Services/GuessReader.cs b/RhSolutions.AddIn/Services/GuessReader.cs
index 6ad8d46..3824950 100644
--- a/RhSolutions.AddIn/Services/GuessReader.cs
+++ b/RhSolutions.AddIn/Services/GuessReader.cs
@@ -149,19 +149,18 @@ public class GuessReader : IReader
private Dictionary<Product, double> GetDictionaryFromColumns(Range productColumn, Range amountColumn)
{
Dictionary<Product, double> result = new();
-
+ var firstRowIndex = 1;
var lastRowIndex = amountColumn.Worksheet
- .Cells[amountColumn.Rows.Count, amountColumn.Column]
+ .Cells[amountColumn.Worksheet.Rows.Count, amountColumn.Column]
.End[XlDirection.xlUp].Row;
_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();
- var amountCells = amountColumn.Value2;
- object currentAmountCell = productColumn.Rows.Count == 1 ? amountCells : amountCells[row, 1];
- var productCells = productColumn.Value2;
- object currentProductCell = productColumn.Rows.Count == 1 ? productCells : productCells[row, 1];
+ object currentAmountCell = worksheet.Cells[row, amountColumn.Column].Value2;
+ object currentProductCell = worksheet.Cells[row, productColumn.Column].Value2;
double? amountValue = currentAmountCell as double?;
if (amountValue == null || amountValue == 0 || currentProductCell == null)