Can guess amount columns with numbers in header
This commit is contained in:
parent
656f565152
commit
f1abb03ac9
@ -47,19 +47,21 @@ public class GuessReader : IReader
|
|||||||
}
|
}
|
||||||
if (currentIndex > productColumnIndex)
|
if (currentIndex > productColumnIndex)
|
||||||
{
|
{
|
||||||
if (IsAmountColumn(range.Columns[currentIndex++]))
|
if (IsAmountColumn(range.Columns[currentIndex]))
|
||||||
{
|
{
|
||||||
amountColumnIndex = currentIndex - 1;
|
amountColumnIndex = currentIndex;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else currentIndex++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (IsAmountColumn(range.Columns[currentIndex--]))
|
if (IsAmountColumn(range.Columns[currentIndex]))
|
||||||
{
|
{
|
||||||
amountColumnIndex = currentIndex + 1;
|
amountColumnIndex = currentIndex;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else currentIndex--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,6 +113,7 @@ public class GuessReader : IReader
|
|||||||
{
|
{
|
||||||
int successCounter = 0;
|
int successCounter = 0;
|
||||||
var cells = column.Value2;
|
var cells = column.Value2;
|
||||||
|
double maxValue = 30000;
|
||||||
|
|
||||||
if (cells == null)
|
if (cells == null)
|
||||||
{
|
{
|
||||||
@ -125,25 +128,30 @@ public class GuessReader : IReader
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double? value = currentCell as double?;
|
double? value = currentCell as double?;
|
||||||
|
|
||||||
if (value == null || value == 0)
|
if (value == null || value == 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value > 30000)
|
if (value > maxValue)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++successCounter > 3)
|
if (column.Rows.Count == 1)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (++successCounter > 1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return successCounter > 0;
|
return successCounter > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<Product, double> GetDictionaryFromColumns(Range productColumn, Range amountColumn)
|
private Dictionary<Product, double> GetDictionaryFromColumns(Range productColumn, Range amountColumn)
|
||||||
|
Loading…
Reference in New Issue
Block a user