From 334111d632632f860cf6ae8a7264eb6caac619d7 Mon Sep 17 00:00:00 2001 From: bulatova_karina Date: Mon, 14 Oct 2024 16:49:30 +0400 Subject: [PATCH] =?UTF-8?q?=D1=82=D1=83=D1=82=20=D0=BD=D0=B0=D0=B4=D0=BE?= =?UTF-8?q?=20=D0=BF=D0=BE=D1=84=D0=B8=D0=BA=D1=81=D0=B8=D1=82=D1=8C=20?= =?UTF-8?q?=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=83...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NonVisualComponents/WordTable.cs | 32 +++++++++---------- COP/Components/SupportClasses/BigTable.cs | 10 +++--- ...lumnDefenition.cs => ColumnDefenitions.cs} | 2 +- COP/WinForms/FormWord.cs | 23 +++++++------ 4 files changed, 33 insertions(+), 34 deletions(-) rename COP/Components/SupportClasses/{ColumnDefenition.cs => ColumnDefenitions.cs} (88%) diff --git a/COP/Components/NonVisualComponents/WordTable.cs b/COP/Components/NonVisualComponents/WordTable.cs index 13b8551..c067ab1 100644 --- a/COP/Components/NonVisualComponents/WordTable.cs +++ b/COP/Components/NonVisualComponents/WordTable.cs @@ -31,11 +31,11 @@ namespace Components.NonVisualComponents throw new ArgumentException("Не заданы все данные"); } - foreach (var columnDefinition in bigTable.ColumnDefinitions) + foreach (var columnDefenition in bigTable.ColumnDefenitions) { - if (string.IsNullOrEmpty(columnDefinition.PropertyName)) + if (string.IsNullOrEmpty(columnDefenition.PropertyName)) { - throw new ArgumentException($"Не задано свойство столбца: {columnDefinition.Header}"); + throw new ArgumentException($"Не задано свойство столбца: {columnDefenition.Header}"); } } @@ -52,13 +52,13 @@ namespace Components.NonVisualComponents Table table = builder.StartTable(); - foreach (var columnDefinition in bigTable.ColumnDefinitions) + foreach (var columnDefenition in bigTable.ColumnDefenitions) { builder.InsertCell(); - builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition.Weight); + builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefenition.Weight); builder.ParagraphFormat.Alignment = ParagraphAlignment.Center; builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center; - builder.Write(columnDefinition.Header); + builder.Write(columnDefenition.Header); } foreach (var mergedColumn in bigTable.MergedColumns) @@ -82,25 +82,25 @@ namespace Components.NonVisualComponents } builder.EndRow(); - foreach (var columnDefinition2 in bigTable.ColumnDefinitions2) + foreach (var columnDefenition in bigTable.ColumnDefenitions) { builder.InsertCell(); - builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition2.Weight); - builder.Write(columnDefinition2.Header); + builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefenition.Weight); + builder.Write(columnDefenition.Header); } builder.EndRow(); int columnIndex; - foreach (var columnDefinition in bigTable.ColumnDefinitions) + foreach (var columnDefinition in bigTable.ColumnDefenitions) { - string currentPropertyName = columnDefinition.PropertyName; + string currentHeader = columnDefinition.Header; columnIndex = 0; - foreach (var columnDefinition2 in bigTable.ColumnDefinitions2) + foreach (var columnDefenition in bigTable.ColumnDefenitions) { - string currentPropertyName1 = columnDefinition2.PropertyName; + string currentHeader1 = columnDefenition.Header; - if (currentPropertyName == currentPropertyName1) + if (currentHeader == currentHeader1) { table.Rows[0].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.First; table.Rows[1].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.Previous; @@ -112,11 +112,11 @@ namespace Components.NonVisualComponents foreach (var item in bigTable.Data) { - foreach (var columnDefinition2 in bigTable.ColumnDefinitions2) + foreach (var columnDefenition in bigTable.ColumnDefenitions) { builder.InsertCell(); var propertyValue = item.GetType() - .GetProperty(columnDefinition2.PropertyName)? + .GetProperty(columnDefenition.PropertyName)? .GetValue(item)?.ToString(); builder.Write(propertyValue ?? ""); diff --git a/COP/Components/SupportClasses/BigTable.cs b/COP/Components/SupportClasses/BigTable.cs index fb29a03..485caa1 100644 --- a/COP/Components/SupportClasses/BigTable.cs +++ b/COP/Components/SupportClasses/BigTable.cs @@ -12,20 +12,20 @@ namespace Components.SupportClasses public string DocumentTitle = string.Empty; - public List ColumnDefinitions; - public List ColumnDefinitions2; + public List Header; + public List ColumnDefenitions; public List Data; public List MergedColumns; - public BigTable(string filePath, string documentTitle, List columnDefinitions, List columnDefinitions2, List data, List mergedColumns) + public BigTable(string filePath, string documentTitle, List header, List columnDefenitions, List data, List mergedColumns) { FilePath = filePath; DocumentTitle = documentTitle; - ColumnDefinitions = columnDefinitions; + Header = header; Data = data; MergedColumns = mergedColumns; - ColumnDefinitions2 = columnDefinitions2; + ColumnDefenitions = columnDefenitions; } } } diff --git a/COP/Components/SupportClasses/ColumnDefenition.cs b/COP/Components/SupportClasses/ColumnDefenitions.cs similarity index 88% rename from COP/Components/SupportClasses/ColumnDefenition.cs rename to COP/Components/SupportClasses/ColumnDefenitions.cs index e419247..d549d51 100644 --- a/COP/Components/SupportClasses/ColumnDefenition.cs +++ b/COP/Components/SupportClasses/ColumnDefenitions.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Components.SupportClasses { - public class ColumnDefinition + public class ColumnDefenitions { public string Header; public string PropertyName; diff --git a/COP/WinForms/FormWord.cs b/COP/WinForms/FormWord.cs index e66082b..00b818b 100644 --- a/COP/WinForms/FormWord.cs +++ b/COP/WinForms/FormWord.cs @@ -58,21 +58,20 @@ namespace WinForms - List columnDefinitions = new List + List header = new List { - new ColumnDefinition { Header = "Работа", PropertyName = "Work", Weight = 35 }, - new ColumnDefinition { Header = "", PropertyName = "Education1", Weight = 35 }, - new ColumnDefinition { Header = "", PropertyName = "Education2", Weight = 10 }, - new ColumnDefinition { Header = "Фамилия", PropertyName = "LastName", Weight = 20 } - + "Работа", + "", + "", + "Фамилия" }; - List columnDefinitions2 = new List + List columnDefenitions = new List { - new ColumnDefinition { Header = "Возраст", PropertyName = "Age", Weight = 20 }, - new ColumnDefinition { Header = "Опыт", PropertyName = "Experience", Weight = 20 }, - new ColumnDefinition { Header = "Должность", PropertyName = "Position", Weight = 20 }, - new ColumnDefinition { Header = "Фамилия", PropertyName = "LastName", Weight = 20 } + new ColumnDefenitions { Header = "Возраст", PropertyName = "Age", Weight = 20 }, + new ColumnDefenitions { Header = "Опыт", PropertyName = "Experience", Weight = 20 }, + new ColumnDefenitions { Header = "Должность", PropertyName = "Position", Weight = 20 }, + new ColumnDefenitions { Header = "Фамилия", PropertyName = "LastName", Weight = 20 } }; List data = new List @@ -92,7 +91,7 @@ namespace WinForms { try { - BigTable bigTable = new(dialog.FileName, "Задание 2", columnDefinitions, columnDefinitions2, data, mergedColumns); + BigTable bigTable = new(dialog.FileName, "Задание 2", header, columnDefenitions, data, mergedColumns); wordTable.CreateTable(bigTable); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); }