From 79ac3cf66242979a3335bcc747cdbe9c4de6a465 Mon Sep 17 00:00:00 2001 From: Polina Date: Fri, 31 May 2024 19:11:00 +0400 Subject: [PATCH] =?UTF-8?q?=E5=87=B8(=EF=BF=A3=E3=83=98=EF=BF=A3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OfficePackage/AbstractSaveToWord.cs | 32 +++++++++---------- .../OfficePackage/Implements/SaveToExcel.cs | 21 ++++++------ .../OfficePackage/Implements/SaveToWord.cs | 29 +++++++++-------- University/UniversityClientApp/Program.cs | 1 - 4 files changed, 43 insertions(+), 40 deletions(-) diff --git a/University/UniversityBusinessLogics/OfficePackage/AbstractSaveToWord.cs b/University/UniversityBusinessLogics/OfficePackage/AbstractSaveToWord.cs index 87aae3e..b3f5402 100644 --- a/University/UniversityBusinessLogics/OfficePackage/AbstractSaveToWord.cs +++ b/University/UniversityBusinessLogics/OfficePackage/AbstractSaveToWord.cs @@ -29,9 +29,9 @@ namespace UniversityBusinessLogics.OfficePackage CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> - { - (text, new WordTextProperties { Size = "24" }) - }, + { + (text, new WordTextProperties { Size = "24" }) + }, TextProperties = new WordTextProperties { Size = "24", @@ -42,23 +42,23 @@ namespace UniversityBusinessLogics.OfficePackage SaveWord(info); } - /// - /// Создание doc-файла - /// - /// + /// + /// Создание doc-файла + /// + /// protected abstract void CreateWord(WordInfo info); - /// - /// Создание абзаца с текстом - /// - /// - /// + /// + /// Создание абзаца с текстом + /// + /// + /// protected abstract void CreateParagraph(WordParagraph paragraph); - /// - /// Сохранение файла - /// - /// + /// + /// Сохранение файла + /// + /// protected abstract void SaveWord(WordInfo info); } } diff --git a/University/UniversityBusinessLogics/OfficePackage/Implements/SaveToExcel.cs b/University/UniversityBusinessLogics/OfficePackage/Implements/SaveToExcel.cs index 23020bd..de19041 100644 --- a/University/UniversityBusinessLogics/OfficePackage/Implements/SaveToExcel.cs +++ b/University/UniversityBusinessLogics/OfficePackage/Implements/SaveToExcel.cs @@ -188,17 +188,17 @@ namespace UniversityBusinessLogics.OfficePackage.Implements _shareStringPart.SharedStringTable = new SharedStringTable(); } - // Create a new worksheet part - var workbookPart = _spreadsheetDocument.AddWorkbookPart(); - workbookPart.Workbook = new Workbook(); + // Создаем лист в книгу + var worksheetPart = workbookpart.AddNewPart(); + worksheetPart.Worksheet = new Worksheet(new SheetData()); - // Set the new worksheet as the active worksheet - var sheets = workbookPart.Workbook.AppendChild(new Sheets()); - var sheet = new Sheet + // Добавляем лист в книгу + var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets()); + var sheet = new Sheet() { Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart), - SheetId = (uint)sheets.ChildElements.Count + 1, - Name = "Sheet1" // You can change the name as needed + SheetId = 1, + Name = "Лист" }; sheets.Append(sheet); @@ -290,7 +290,10 @@ namespace UniversityBusinessLogics.OfficePackage.Implements } } - var mergeCell = new MergeCell { Reference = excelParams.Merge }; + var mergeCell = new MergeCell() + { + Reference = new StringValue(excelParams.Merge) + }; mergeCells.Append(mergeCell); } diff --git a/University/UniversityBusinessLogics/OfficePackage/Implements/SaveToWord.cs b/University/UniversityBusinessLogics/OfficePackage/Implements/SaveToWord.cs index f9be513..9698176 100644 --- a/University/UniversityBusinessLogics/OfficePackage/Implements/SaveToWord.cs +++ b/University/UniversityBusinessLogics/OfficePackage/Implements/SaveToWord.cs @@ -12,11 +12,11 @@ namespace UniversityBusinessLogics.OfficePackage.Implements private Body? _docBody; - /// - /// Получение типа выравнивания - /// - /// - /// + /// + /// Получение типа выравнивания + /// + /// + /// private static JustificationValues GetJustificationValues(WordJustificationType type) { return type switch @@ -27,10 +27,10 @@ namespace UniversityBusinessLogics.OfficePackage.Implements }; } - /// - /// Настройки страницы - /// - /// + /// + /// Настройки страницы + /// + /// private static SectionProperties CreateSectionProperties() { var properties = new SectionProperties(); @@ -45,11 +45,11 @@ namespace UniversityBusinessLogics.OfficePackage.Implements return properties; } - /// - /// Задание форматирования для абзаца - /// - /// - /// + /// + /// Задание форматирования для абзаца + /// + /// + /// private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties) { if (paragraphProperties == null) @@ -144,3 +144,4 @@ namespace UniversityBusinessLogics.OfficePackage.Implements } } } + diff --git a/University/UniversityClientApp/Program.cs b/University/UniversityClientApp/Program.cs index 50e4ed0..eaec648 100644 --- a/University/UniversityClientApp/Program.cs +++ b/University/UniversityClientApp/Program.cs @@ -18,7 +18,6 @@ builder.Services.AddSession(); // builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); -builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient();