127 lines
3.1 KiB
C#
127 lines
3.1 KiB
C#
|
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperEnums;
|
|||
|
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels;
|
|||
|
|
|||
|
namespace ComputerHardwareStoreBusinessLogic.OfficePackage
|
|||
|
{
|
|||
|
public abstract class AbstractSaveToExcel
|
|||
|
{
|
|||
|
public void CreateReportProduct(ExcelInfo info)
|
|||
|
{
|
|||
|
CreateExcel(info);
|
|||
|
InsertCellInWorksheet(new ExcelCellParameters
|
|||
|
{
|
|||
|
ColumnName = "A",
|
|||
|
RowIndex = 1,
|
|||
|
Text = info.Title,
|
|||
|
StyleInfo = ExcelStyleInfoType.Title
|
|||
|
});
|
|||
|
MergeCells(new ExcelMergeParameters
|
|||
|
{
|
|||
|
CellFromName = "A1",
|
|||
|
CellToName = "C1"
|
|||
|
});
|
|||
|
uint rowIndex = 2;
|
|||
|
foreach (var pb in info.ProductBuilds)
|
|||
|
{
|
|||
|
InsertCellInWorksheet(new ExcelCellParameters
|
|||
|
{
|
|||
|
ColumnName = "A",
|
|||
|
RowIndex = rowIndex,
|
|||
|
Text = pb.ProductName,
|
|||
|
StyleInfo = ExcelStyleInfoType.Text
|
|||
|
});
|
|||
|
rowIndex++;
|
|||
|
foreach (var Build in pb.Builds)
|
|||
|
{
|
|||
|
InsertCellInWorksheet(new ExcelCellParameters
|
|||
|
{
|
|||
|
ColumnName = "B",
|
|||
|
RowIndex = rowIndex,
|
|||
|
Text = Build.Item1,
|
|||
|
StyleInfo =
|
|||
|
ExcelStyleInfoType.TextWithBroder
|
|||
|
});
|
|||
|
InsertCellInWorksheet(new ExcelCellParameters
|
|||
|
{
|
|||
|
ColumnName = "C",
|
|||
|
RowIndex = rowIndex,
|
|||
|
Text = Build.Item2.ToString(),
|
|||
|
StyleInfo =
|
|||
|
ExcelStyleInfoType.TextWithBroder
|
|||
|
});
|
|||
|
rowIndex++;
|
|||
|
}
|
|||
|
InsertCellInWorksheet(new ExcelCellParameters
|
|||
|
{
|
|||
|
ColumnName = "A",
|
|||
|
RowIndex = rowIndex,
|
|||
|
Text = "Итого",
|
|||
|
StyleInfo = ExcelStyleInfoType.Text
|
|||
|
});
|
|||
|
rowIndex++;
|
|||
|
}
|
|||
|
SaveExcel(info);
|
|||
|
}
|
|||
|
public void CreateReportBuild(ExcelInfo info)
|
|||
|
{
|
|||
|
CreateExcel(info);
|
|||
|
InsertCellInWorksheet(new ExcelCellParameters
|
|||
|
{
|
|||
|
ColumnName = "A",
|
|||
|
RowIndex = 1,
|
|||
|
Text = info.Title,
|
|||
|
StyleInfo = ExcelStyleInfoType.Title
|
|||
|
});
|
|||
|
MergeCells(new ExcelMergeParameters
|
|||
|
{
|
|||
|
CellFromName = "A1",
|
|||
|
CellToName = "C1"
|
|||
|
});
|
|||
|
uint rowIndex = 2;
|
|||
|
foreach (var bp in info.BuildProducts)
|
|||
|
{
|
|||
|
InsertCellInWorksheet(new ExcelCellParameters
|
|||
|
{
|
|||
|
ColumnName = "A",
|
|||
|
RowIndex = rowIndex,
|
|||
|
Text = bp.BuildName,
|
|||
|
StyleInfo = ExcelStyleInfoType.Text
|
|||
|
});
|
|||
|
rowIndex++;
|
|||
|
foreach (var Canned in bp.Products)
|
|||
|
{
|
|||
|
InsertCellInWorksheet(new ExcelCellParameters
|
|||
|
{
|
|||
|
ColumnName = "B",
|
|||
|
RowIndex = rowIndex,
|
|||
|
Text = Canned.Item1,
|
|||
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
|||
|
});
|
|||
|
InsertCellInWorksheet(new ExcelCellParameters
|
|||
|
{
|
|||
|
ColumnName = "C",
|
|||
|
RowIndex = rowIndex,
|
|||
|
Text = Canned.Item2.ToString(),
|
|||
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
|||
|
});
|
|||
|
rowIndex++;
|
|||
|
}
|
|||
|
InsertCellInWorksheet(new ExcelCellParameters
|
|||
|
{
|
|||
|
ColumnName = "A",
|
|||
|
RowIndex = rowIndex,
|
|||
|
Text = "Итого",
|
|||
|
StyleInfo = ExcelStyleInfoType.Text
|
|||
|
});
|
|||
|
rowIndex++;
|
|||
|
}
|
|||
|
SaveExcel(info);
|
|||
|
}
|
|||
|
protected abstract void CreateExcel(ExcelInfo info);
|
|||
|
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
|||
|
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
|||
|
protected abstract void SaveExcel(ExcelInfo info);
|
|||
|
|
|||
|
}
|
|||
|
}
|