diff --git a/ExexForm2/Form1.cs b/ExexForm2/Form1.cs index 1cc6726..832257e 100644 --- a/ExexForm2/Form1.cs +++ b/ExexForm2/Form1.cs @@ -87,14 +87,15 @@ namespace ExexForm2 }; var headers = new List { "First Name", "Last Name", "Age" }; + var commonHeaders = new List { "Name", "", "" }; var propertyNames = new List { "FirstName", "LastName", "Age" }; var rowHeights = new List { 20, 20 }; var mergeCells = new List<(int startRow, int endRow, int startColumn, int endColumn)> { - //(0, 0, 0, 1) // Объединение первых двух столбцов в первой строке - }; + (0, 1, 0, 0) // 0 и 1 ячейки по вертикали первой колонки + }; - generator.GeneratePdf(fileName, "Example Document", mergeCells, rowHeights, headers, propertyNames, data1); + generator.GeneratePdf(fileName, "Example Document", mergeCells, rowHeights, headers, commonHeaders, propertyNames, data1); } } } \ No newline at end of file diff --git a/Library14Petrushin/PdfColGroupTable.cs b/Library14Petrushin/PdfColGroupTable.cs index 4774d2e..8b0143c 100644 --- a/Library14Petrushin/PdfColGroupTable.cs +++ b/Library14Petrushin/PdfColGroupTable.cs @@ -18,6 +18,7 @@ namespace Library14Petrushin List<(int startRow, int endRow, int startColumn, int endColumn)> mergeCells, List rowHeights, List headers, + List commonHeaders, List propertyNames, List data) { @@ -58,6 +59,15 @@ namespace Library14Petrushin double columnWidth = (page.Width - 2 * margin) / (headers.Count + 1); // РЁРёСЂРёРЅР° столбца // Отрисовка шапки + + for (int col = 0; col < commonHeaders.Count; col++) + { + gfx.DrawString(commonHeaders[col], font, XBrushes.Black, new XRect(x, y + col * rowHeight, columnWidth, rowHeight), XStringFormats.CenterLeft); + gfx.DrawRectangle(XPens.Black, new XRect(x, y + col * rowHeight, columnWidth, rowHeight)); // Добавляем рамку + } + + x += columnWidth; + for (int col = 0; col < headers.Count; col++) { gfx.DrawString(headers[col], font, XBrushes.Black, new XRect(x, y + col * rowHeight, columnWidth, rowHeight), XStringFormats.CenterLeft);