diff --git a/Components/NotVisualComponents/PdfTable.cs b/Components/NotVisualComponents/PdfTable.cs index 45eb867..481023d 100644 --- a/Components/NotVisualComponents/PdfTable.cs +++ b/Components/NotVisualComponents/PdfTable.cs @@ -115,30 +115,31 @@ namespace BarsukovComponents.NotVisualComponents foreach (var item in data) { var properties = item.GetType().GetProperties(); - if (properties.Count() != cellsCount) - { - throw new Exception("Кол-во полей объекта не совпадает с кол-вом колонок"); - } + //if (properties.Count() != cellsCount) + //{ + // throw new Exception("Кол-во полей объекта не совпадает с кол-вом колонок"); + //} - for (int i = 0; i < properties.Count(); i++) + + + + for (int i = 0; i < cellsCount; i++) { - var property = properties[i]; - var propValue = property.GetValue(item); - if (propValue == null) - { - throw new Exception("Пустое поле"); - } - if (property.Name == colInfo[i].PropertyName) + var property = properties.FirstOrDefault(p => p.Name == colInfo[i].PropertyName); + if (property != null) { + var propValue = property.GetValue(item); + if (propValue == null) + { + throw new Exception("Пустое поле"); + } if (table.Rows.Count <= rowData) { table.AddRow(); } table.Rows[rowData].Cells[i].AddParagraph(propValue.ToString()); - continue; } } - rowData++; } var renderer = new PdfDocumentRenderer(true); diff --git a/CustomComboBox/TestApp/Form1.cs b/CustomComboBox/TestApp/Form1.cs index d984078..11d52b5 100644 --- a/CustomComboBox/TestApp/Form1.cs +++ b/CustomComboBox/TestApp/Form1.cs @@ -115,13 +115,13 @@ namespace TestApp { new ColumnInfo("First","First Prop",50), new ColumnInfo("Second","Second Prop",100), - new ColumnInfo("Third","Third Prop",100), + //new ColumnInfo("Third","Third Prop",100), new ColumnInfo("Fourth","Fourth Prop",200), new ColumnInfo("Fifth","Fifth Prop",50), }; List mergeCells = new List() { - new MergeCells("Merged columns", new int[] {3,4}) + new MergeCells("Merged columns", new int[] {2,3}) }; List workers = new List() {