diff --git a/FlowerShopBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/FlowerShopBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 4d00419..619115a 100644 --- a/FlowerShopBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/FlowerShopBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -26,7 +26,8 @@ namespace FlowerShopBusinessLogic.OfficePackage { CreateParagraph(new WordParagraph { - Texts = new List<(string, WordTextProperties)> { (flower.FlowerName, new WordTextProperties { Size = "24", }) }, + Texts = new List<(string, WordTextProperties)> { (flower.FlowerName, new WordTextProperties { Size = "24", Bold = true }), + (" - цена " + flower.Price.ToString(), new WordTextProperties { Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", diff --git a/FlowerShopBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/FlowerShopBusinessLogic/OfficePackage/Implements/SaveToExcel.cs index 501e2be..d7e53fa 100644 --- a/FlowerShopBusinessLogic/OfficePackage/Implements/SaveToExcel.cs +++ b/FlowerShopBusinessLogic/OfficePackage/Implements/SaveToExcel.cs @@ -156,30 +156,24 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements var tableStyles = new TableStyles() { Count = 0U, - DefaultTableStyle = - "TableStyleMedium2", + DefaultTableStyle ="TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16" }; var stylesheetExtensionList = new StylesheetExtensionList(); var stylesheetExtension1 = new StylesheetExtension() { - Uri = - "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" + Uri ="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" }; - stylesheetExtension1.AddNamespaceDeclaration("x14", - "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"); + stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"); stylesheetExtension1.Append(new SlicerStyles() { - DefaultSlicerStyle = - "SlicerStyleLight1" + DefaultSlicerStyle = "SlicerStyleLight1" }); var stylesheetExtension2 = new StylesheetExtension() { - Uri = - "{9260A510-F301-46a8-8635-F512D64BE5F5}" + Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" }; - stylesheetExtension2.AddNamespaceDeclaration("x15", - "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"); + stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"); stylesheetExtension2.Append(new TimelineStyles() { DefaultTimelineStyle = "TimeSlicerStyleLight1" @@ -211,6 +205,8 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements _ => 0U, }; } + + // создаем книгу, добавляем туда листы protected override void CreateExcel(ExcelInfo info) { _spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, @@ -235,8 +231,7 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements var worksheetPart = workbookpart.AddNewPart(); worksheetPart.Worksheet = new Worksheet(new SheetData()); // Добавляем лист в книгу - var sheets = - _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets()); + var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets()); var sheet = new Sheet() { Id = @@ -247,8 +242,8 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements sheets.Append(sheet); _worksheet = worksheetPart.Worksheet; } - protected override void InsertCellInWorksheet(ExcelCellParameters - excelParams) + + protected override void InsertCellInWorksheet(ExcelCellParameters excelParams) { if (_worksheet == null || _shareStringPart == null) { @@ -261,8 +256,7 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements } // Ищем строку, либо добавляем ее Row row; - if (sheetData.Elements().Where(r => r.RowIndex! == - excelParams.RowIndex).Any()) + if (sheetData.Elements().Where(r => r.RowIndex! == excelParams.RowIndex).Any()) { row = sheetData.Elements().Where(r => r.RowIndex! == excelParams.RowIndex).First(); @@ -274,11 +268,9 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements } // Ищем нужную ячейку Cell cell; - if (row.Elements().Where(c => c.CellReference!.Value == - excelParams.CellReference).Any()) + if (row.Elements().Where(c => c.CellReference!.Value == excelParams.CellReference).Any()) { - cell = row.Elements().Where(c => c.CellReference!.Value == - excelParams.CellReference).First(); + cell = row.Elements().Where(c => c.CellReference!.Value == excelParams.CellReference).First(); } else { @@ -303,15 +295,13 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements cell = newCell; } // вставляем новый текст - _shareStringPart.SharedStringTable.AppendChild(new - SharedStringItem(new Text(excelParams.Text))); + _shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text))); _shareStringPart.SharedStringTable.Save(); - cell.CellValue = new - CellValue((_shareStringPart.SharedStringTable.Elements().Count( - ) - 1).ToString()); + cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements().Count() - 1).ToString()); cell.DataType = new EnumValue(CellValues.SharedString); cell.StyleIndex = GetStyleValue(excelParams.StyleInfo); } + // объединение ячеек protected override void MergeCells(ExcelMergeParameters excelParams) { if (_worksheet == null)