| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using QuestPDF.ConformanceTests.TestEngine;
- using QuestPDF.Drawing;
- using QuestPDF.Fluent;
- using QuestPDF.Helpers;
- using QuestPDF.Infrastructure;
- namespace QuestPDF.ConformanceTests.Table;
- internal class TableWithVerticalHeadersTests : ConformanceTestBase
- {
- protected override Document GetDocumentUnderTest()
- {
- return Document
- .Create(document =>
- {
- document.Page(page =>
- {
- page.Margin(60);
- page.Content()
- .Shrink()
- .Border(1)
- .BorderColor(Colors.Grey.Darken1)
- .SemanticTable()
- .Table(table =>
- {
- table.ColumnsDefinition(columns =>
- {
- columns.RelativeColumn();
- columns.RelativeColumn();
- columns.RelativeColumn();
- columns.RelativeColumn();
- });
-
- table.Header(header =>
- {
- header.Cell().Element(HeaderCellStyle).Text("Name");
- header.Cell().Element(HeaderCellStyle).Text("Position");
- header.Cell().Element(HeaderCellStyle).Text("Department");
- header.Cell().Element(HeaderCellStyle).Text("Experience");
- });
- // Row 1:
- table.Cell().Element(CellStyle).Text("John Smith");
- table.Cell().Element(CellStyle).Text("Senior Developer");
- table.Cell().Element(CellStyle).Text("Engineering");
- table.Cell().Element(CellStyle).Text("5 years");
-
- // Row 2:
- table.Cell().Element(CellStyle).Text("Jane Doe");
- table.Cell().Element(CellStyle).Text("UX Designer");
- table.Cell().Element(CellStyle).Text("Design");
- table.Cell().Element(CellStyle).Text("3 years");
- IContainer HeaderCellStyle(IContainer container) =>
- container
- .Border(1)
- .BorderColor(Colors.Grey.Lighten2)
- .Background(Colors.Grey.Lighten3)
- .Padding(8)
- .AlignMiddle()
- .DefaultTextStyle(x => x.Bold());
- IContainer CellStyle(IContainer container) =>
- container
- .Border(1)
- .BorderColor(Colors.Grey.Lighten2)
- .Padding(8);
- });
- });
- });
- }
- protected override SemanticTreeNode? GetExpectedSemanticTree()
- {
- return ExpectedSemanticTree.DocumentRoot(root =>
- {
- root.Child("Table", table =>
- {
- table.Child("THead", thead =>
- {
- thead.Child("TR", row =>
- {
- row.Child("TH", th => th.Attribute("Table", "Scope", "Column").Child("P"));
- row.Child("TH", th => th.Attribute("Table", "Scope", "Column").Child("P"));
- row.Child("TH", th => th.Attribute("Table", "Scope", "Column").Child("P"));
- row.Child("TH", th => th.Attribute("Table", "Scope", "Column").Child("P"));
- });
- });
-
- table.Child("TBody", tbody =>
- {
- tbody.Child("TR", row =>
- {
- row.Child("TD", td => td.Child("P"));
- row.Child("TD", td => td.Child("P"));
- row.Child("TD", td => td.Child("P"));
- row.Child("TD", td => td.Child("P"));
- });
- tbody.Child("TR", row =>
- {
- row.Child("TD", td => td.Child("P"));
- row.Child("TD", td => td.Child("P"));
- row.Child("TD", td => td.Child("P"));
- row.Child("TD", td => td.Child("P"));
- });
- });
- });
- });
- }
- }
|