From 4d01a456e3c5faea7a23e7e39b41e1a1bd8beef0 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Fri, 1 Apr 2022 16:35:25 +0300 Subject: [PATCH] Fix cast failing on non-digital value in amount field --- src/PriceListTools/SourcePriceList.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PriceListTools/SourcePriceList.cs b/src/PriceListTools/SourcePriceList.cs index d03d776..b11e060 100644 --- a/src/PriceListTools/SourcePriceList.cs +++ b/src/PriceListTools/SourcePriceList.cs @@ -77,9 +77,9 @@ namespace RehauSku.PriceListTools for (int row = AmountCell.Row + 1; row <= Sheet.Cells[Sheet.Rows.Count, AmountCell.Column].End[XlDirection.xlUp].Row; row++) { - object amount = Sheet.Cells[row, AmountCell.Column].Value2; + double? amount = Sheet.Cells[row, AmountCell.Column].Value2 as double?; - if (amount != null && (double)amount != 0) + if (amount != null && amount.Value != 0) { object group = Sheet.Cells[row, GroupCell.Column].Value2; object name = Sheet.Cells[row, NameCell.Column].Value2; @@ -95,12 +95,12 @@ namespace RehauSku.PriceListTools if (PositionAmount.ContainsKey(p)) { - PositionAmount[p] += (double)amount; + PositionAmount[p] += amount.Value; } else { - PositionAmount.Add(p, (double)amount); + PositionAmount.Add(p, amount.Value); } } }