Compare commits

..

No commits in common. "c17a7faddcdc649f476d47b88756683dec2c167d" and "31b37da456983df5c04e3f7e9fffdb345b9377a4" have entirely different histories.

2 changed files with 7 additions and 18 deletions

View File

@ -87,15 +87,14 @@ namespace ExexForm2
}; };
var headers = new List<string> { "First Name", "Last Name", "Age" }; var headers = new List<string> { "First Name", "Last Name", "Age" };
var commonHeaders = new List<string> { "Name", "", "" };
var propertyNames = new List<string> { "FirstName", "LastName", "Age" }; var propertyNames = new List<string> { "FirstName", "LastName", "Age" };
var rowHeights = new List<double> { 20, 20 }; var rowHeights = new List<double> { 20, 20 };
var mergeCells = new List<(int startRow, int endRow, int startColumn, int endColumn)> var mergeCells = new List<(int startRow, int endRow, int startColumn, int endColumn)>
{ {
(0, 1, 0, 0) // 0 è 1 ÿ÷åéêè ïî âåðòèêàëè ïåðâîé êîëîíêè (0, 0, 0, 1) // Îáúåäèíåíèå ïåðâûõ äâóõ ñòîëáöîâ â ïåðâîé ñòðîêå
}; };
generator.GeneratePdf(fileName, "Example Document", mergeCells, rowHeights, headers, commonHeaders, propertyNames, data1); generator.GeneratePdf(fileName, "Example Document", mergeCells, rowHeights, headers, propertyNames, data1);
} }
} }
} }

View File

@ -18,7 +18,6 @@ namespace Library14Petrushin
List<(int startRow, int endRow, int startColumn, int endColumn)> mergeCells, List<(int startRow, int endRow, int startColumn, int endColumn)> mergeCells,
List<double> rowHeights, List<double> rowHeights,
List<string> headers, List<string> headers,
List<string> commonHeaders,
List<string> propertyNames, List<string> propertyNames,
List<T> data) List<T> data)
{ {
@ -59,15 +58,6 @@ namespace Library14Petrushin
double columnWidth = (page.Width - 2 * margin) / (headers.Count + 1); // Ширина столбца 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++) 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); gfx.DrawString(headers[col], font, XBrushes.Black, new XRect(x, y + col * rowHeight, columnWidth, rowHeight), XStringFormats.CenterLeft);
@ -77,12 +67,12 @@ namespace Library14Petrushin
x += columnWidth; x += columnWidth;
// Отрисовка данных // Отрисовка данных
for (int col = 0; col < data.Count; col++) for (int row = 0; row < data.Count; row++)
{ {
for (int row = 0; row < propertyNames.Count; row++) var item = data[row];
for (int col = 0; col < propertyNames.Count; col++)
{ {
var item = data[col]; var property = item.GetType().GetProperty(propertyNames[col]);
var property = item.GetType().GetProperty(propertyNames[row]);
if (property != null) if (property != null)
{ {
var value = property.GetValue(item)?.ToString() ?? string.Empty; var value = property.GetValue(item)?.ToString() ?? string.Empty;