Excel report implement
This commit is contained in:
parent
8428b895a8
commit
10a344f0b1
@ -67,7 +67,7 @@ namespace AutoWorkshopBusinessLogic.BusinessLogics
|
||||
|
||||
public void SaveRepairComponentToExcelFile(ReportBindingModel Model)
|
||||
{
|
||||
_saveToExcel.CreateReport(new ExcelInfo
|
||||
_saveToExcel.CreateReport(new ExcelRepairsInfo
|
||||
{
|
||||
FileName = Model.FileName,
|
||||
Title = "Список ремонтов",
|
||||
|
@ -5,7 +5,7 @@ namespace AutoWorkshopBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToExcel
|
||||
{
|
||||
public void CreateReport(ExcelInfo Info)
|
||||
public void CreateReport(ExcelRepairsInfo Info)
|
||||
{
|
||||
CreateExcel(Info);
|
||||
|
||||
@ -78,13 +78,88 @@ namespace AutoWorkshopBusinessLogic.OfficePackage
|
||||
|
||||
SaveExcel(Info);
|
||||
}
|
||||
|
||||
protected abstract void CreateExcel(ExcelInfo Info);
|
||||
|
||||
public void CreateShopPizzasReport(ExcelShopsInfo 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 ShopRep in Info.ShopRepairs)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = RowIndex,
|
||||
Text = ShopRep.ShopName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
RowIndex++;
|
||||
|
||||
foreach (var (Repair, Count) in ShopRep.Repairs)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = RowIndex,
|
||||
Text = Repair,
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = RowIndex,
|
||||
Text = Count.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
RowIndex++;
|
||||
}
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = RowIndex,
|
||||
Text = "Итого",
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = RowIndex,
|
||||
Text = ShopRep.TotalCount.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
RowIndex++;
|
||||
}
|
||||
|
||||
SaveExcel(Info);
|
||||
}
|
||||
|
||||
protected abstract void CreateExcel(IDocumentInfo Info);
|
||||
|
||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters ExcelParams);
|
||||
|
||||
protected abstract void MergeCells(ExcelMergeParameters ExcelParams);
|
||||
|
||||
protected abstract void SaveExcel(ExcelInfo Info);
|
||||
protected abstract void SaveExcel(IDocumentInfo Info);
|
||||
}
|
||||
}
|
||||
|
@ -80,11 +80,11 @@ namespace AutoWorkshopBusinessLogic.OfficePackage
|
||||
SaveWord(Info);
|
||||
}
|
||||
|
||||
protected abstract void CreateWord(IWordInfo Info);
|
||||
protected abstract void CreateWord(IDocumentInfo Info);
|
||||
|
||||
protected abstract void CreateParagraph(WordParagraph Paragraph);
|
||||
|
||||
protected abstract void SaveWord(IWordInfo Info);
|
||||
protected abstract void SaveWord(IDocumentInfo Info);
|
||||
|
||||
protected abstract void CreateTable(List<string> Colums);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelInfo
|
||||
public class ExcelRepairsInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelShop : IWordInfo
|
||||
public class ExcelShopsInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public interface IWordInfo
|
||||
public interface IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfGroupedOrdersInfo : IWordInfo
|
||||
public class PdfGroupedOrdersInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordRepairsInfo : IWordInfo
|
||||
public class WordRepairsInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordShopsInfo : IWordInfo
|
||||
public class WordShopsInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
|
@ -139,7 +139,7 @@ namespace AutoWorkshopBusinessLogic.OfficePackage.Implements
|
||||
};
|
||||
}
|
||||
|
||||
protected override void CreateExcel(ExcelInfo Info)
|
||||
protected override void CreateExcel(IDocumentInfo Info)
|
||||
{
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(Info.FileName, SpreadsheetDocumentType.Workbook);
|
||||
|
||||
@ -269,7 +269,7 @@ namespace AutoWorkshopBusinessLogic.OfficePackage.Implements
|
||||
MergeCells.Append(MergeCell);
|
||||
}
|
||||
|
||||
protected override void SaveExcel(ExcelInfo Info)
|
||||
protected override void SaveExcel(IDocumentInfo Info)
|
||||
{
|
||||
if (_spreadsheetDocument == null)
|
||||
return;
|
||||
|
@ -64,7 +64,7 @@ namespace AutoWorkshopBusinessLogic.OfficePackage.Implements
|
||||
return Properties;
|
||||
}
|
||||
|
||||
protected override void CreateWord(IWordInfo Info)
|
||||
protected override void CreateWord(IDocumentInfo Info)
|
||||
{
|
||||
_wordDocument = WordprocessingDocument.Create(Info.FileName, WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
@ -103,7 +103,7 @@ namespace AutoWorkshopBusinessLogic.OfficePackage.Implements
|
||||
_docBody.AppendChild(DocParagraph);
|
||||
}
|
||||
|
||||
protected override void SaveWord(IWordInfo Info)
|
||||
protected override void SaveWord(IDocumentInfo Info)
|
||||
{
|
||||
if (_docBody == null || _wordDocument == null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user