RhSolutions-AddIn/src/PriceListTools/CombineTool.cs

42 lines
1.4 KiB
C#
Raw Normal View History

2022-01-09 10:37:25 +03:00
using Microsoft.Office.Interop.Excel;
2022-01-27 17:34:03 +03:00
using System.Collections.Generic;
2022-02-02 10:23:50 +03:00
using RehauSku.Interface;
using System.Linq;
namespace RehauSku.PriceListTools
{
2022-02-02 18:02:17 +03:00
internal class CombineTool : AbstractTool
{
2022-02-02 18:05:49 +03:00
public List<SourcePriceList> SourceFiles;
2022-01-27 17:34:03 +03:00
public void FillTarget()
{
2022-02-04 09:17:12 +03:00
ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(file => file.PositionAmount.Count));
ResultBar = new ResultBar();
2022-02-02 10:23:50 +03:00
2022-02-02 18:05:49 +03:00
foreach (SourcePriceList source in SourceFiles)
{
2022-01-27 17:34:03 +03:00
TargetFile.Sheet.Columns[TargetFile.amountCell.Column]
2022-01-26 17:41:46 +03:00
.EntireColumn
.Insert(XlInsertShiftDirection.xlShiftToRight, XlInsertFormatOrigin.xlFormatFromRightOrBelow);
2022-01-09 10:37:25 +03:00
2022-01-28 12:37:02 +03:00
Range newColumnHeader = TargetFile.Sheet.Cells[TargetFile.amountCell.Row, TargetFile.amountCell.Column - 1];
newColumnHeader.Value2 = $"{source.Name}";
newColumnHeader.WrapText = true;
2022-01-27 17:34:03 +03:00
2022-02-02 10:23:50 +03:00
foreach (var kvp in source.PositionAmount)
{
2022-02-03 21:44:24 +03:00
FillPositionAmountToColumns(kvp, TargetFile.amountCell.Column - 1, TargetFile.amountCell.Column);
2022-02-04 09:17:12 +03:00
ProgressBar.Update();
2022-02-02 10:23:50 +03:00
}
2022-01-27 20:43:19 +03:00
}
2022-01-09 10:37:25 +03:00
2022-01-27 20:43:19 +03:00
FilterByAmount();
2022-02-04 09:17:12 +03:00
ResultBar.Update();
2022-01-09 10:37:25 +03:00
Interface.Dialog.SaveWorkbookAs();
2022-02-04 09:17:12 +03:00
ExcelApp.StatusBar = false;
}
}
}