using XReports.Interfaces;
using XReports.SchemaBuilders;
using System.Collections.Generic;
using XReports.Extensions;
public string Name { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public int Age { get; set; }
public static void Main()
HorizontalReportSchemaBuilder<Customer> builder = new HorizontalReportSchemaBuilder<Customer>();
builder.AddRow("Name", (Customer x) => x.Name);
builder.AddRow("Phone", (Customer x) => x.Phone);
builder.AddRow("Email", (Customer x) => x.Email);
builder.AddRow("Age", (Customer x) => x.Age);
builder.AddComplexHeader(0, "Contact Info", "Phone", "Email");
HorizontalReportSchema<Customer> schema = builder.BuildSchema();
IEnumerable<Customer> dataSource = new Customer[]
new Customer { Name = "John Doe", Email = "john@example.com", Age = 23, Phone = "1111111111" },
new Customer { Name = "Jane Doe", Email = "jane@example.com", Age = 22, Phone = "2222222222" },
IReportTable<ReportCell> reportTable = schema.BuildReportTable(dataSource);
List<string> cellsTexts = new List<string>();
foreach (IEnumerable<ReportCell> row in reportTable.Rows)
foreach (ReportCell cell in row)
cellsTexts.Add(string.Format("{0,-20}", string.Empty));
cellsTexts.Add(string.Format($"{{0,-{cell.ColumnSpan * 23 - 3}}}", cell.GetValue<string>()));
columnSpan = cell.ColumnSpan;
Console.WriteLine(string.Join(" | ", cellsTexts));