Headers Find optimization
This commit is contained in:
parent
159ac0ec57
commit
1f5aebe62a
@ -93,26 +93,28 @@ public class ExcelReader : IReader, IDisposable
|
||||
string wbName = Path.GetFileNameWithoutExtension(
|
||||
worksheet.Parent.Name);
|
||||
|
||||
Range AmountCell = worksheet.Cells.Find(headers["Amount"]),
|
||||
SkuCell = worksheet.Cells.Find(headers["Sku"]),
|
||||
ProductLineCell = worksheet.Cells.Find(headers["ProductLine"]),
|
||||
NameCell = worksheet.Cells.Find(headers["Name"]),
|
||||
MeasureCell = worksheet.Cells.Find(headers["Measure"]);
|
||||
var lastRowIndex = worksheet.Cells[worksheet.Rows.Count, SkuCell.Column]
|
||||
Range amountCell = worksheet.Cells.Find(headers["Amount"]);
|
||||
Range headerRow = amountCell.EntireRow;
|
||||
Range skuCell = headerRow.Find(headers["Sku"]),
|
||||
productLineCell = headerRow.Find(headers["ProductLine"]),
|
||||
nameCell = headerRow.Find(headers["Name"]),
|
||||
measureCell = headerRow.Find(headers["Measure"]);
|
||||
|
||||
var lastRowIndex = worksheet.Cells[worksheet.Rows.Count, skuCell.Column]
|
||||
.End[XlDirection.xlUp].Row;
|
||||
|
||||
Dictionary<Product, double> readResult = new();
|
||||
|
||||
for (int row = AmountCell.Row + 1; row <= lastRowIndex; row++)
|
||||
for (int row = amountCell.Row + 1; row <= lastRowIndex; row++)
|
||||
{
|
||||
double? amount = worksheet.Cells[row, AmountCell.Column].Value2 as double?;
|
||||
double? amount = worksheet.Cells[row, amountCell.Column].Value2 as double?;
|
||||
|
||||
if (amount != null && amount.Value != 0)
|
||||
{
|
||||
object productLine = worksheet.Cells[row, ProductLineCell.Column].Value2;
|
||||
object name = worksheet.Cells[row, NameCell.Column].Value2;
|
||||
object sku = worksheet.Cells[row, SkuCell.Column].Value2;
|
||||
object measure = worksheet.Cells[row, MeasureCell.Column].Value2;
|
||||
object productLine = worksheet.Cells[row, productLineCell.Column].Value2;
|
||||
object name = worksheet.Cells[row, nameCell.Column].Value2;
|
||||
object sku = worksheet.Cells[row, skuCell.Column].Value2;
|
||||
object measure = worksheet.Cells[row, measureCell.Column].Value2;
|
||||
var productMeasure = measure?.ToString() switch
|
||||
{
|
||||
"м" => Measure.M,
|
||||
|
Loading…
Reference in New Issue
Block a user