var headers = new List
{
new Header("ID", "رقم الهوية", x => ((Product)x).ID, 1, type: HeaderType.Primitive),
new Header("Product Name", "اسم السلعة", x => ((Product)x).ProductName, 2, type: HeaderType.Primitive),
new Header("Цена", "Цена", x => ((Продукт)x).Цена, 4, ширина: 2, тип: HeaderType.Primitive),
new Header("Colors", "الالوان", x => ((Product)x).Colors, 5, ширина: 2, тип: HeaderType.ListOfPrimitives),
new Header("Types", "الأنواع",
x => ((Product )x).Types,
3,
ширина: 2,
childHeaders: новый список
{
новый заголовок("Мой идентификатор", "رقم الهوية", y => ((MyType)y).Id, тип: HeaderType.Primitive),
new Header("MY Value", "القيمة", y => ((MyType)y).Value, type: HeaderType .Primitive)
},
type: HeaderType.ComplexType)
};
var Products = новый список
{
Код: Выделить всё
new Product { ID = 1, ProductName = "Product A", Price = 99.99m ,Types = new List{new MyType { Id = 1, Value = "Type1" },new MyType { Id = 2, Value = "Type2" }}, Colors = new List { "Red", "Blue", "Green", "Yellow" } } ,}
когда я хочу просмотреть данные типов и foreach внутри объекта, данные отображаются в столбце, а не построчно
этот код для просмотра данных
foreach (строка var в данных)
{
var maxListCount = (uint)GetMaxListCount(row);
foreach (заголовок var в headerList)
{
var value = header.Accessor(row);
if (значение — список IEnumerable)
{
Код: Выделить всё
if (header.Type == HeaderType.ComplexType)
{
var myProperities = 0;
foreach (var complexItem in list)
{
foreach (var complexHeader in headersWithChildren)
{
myProperities = complexHeader.ChildHeaders.Count;
table.Cell().RowSpan(maxListCount).Column(
column =>
{
foreach (var subHeader in complexHeader.ChildHeaders)
{
var subHeaderValue = subHeader.Accessor(complexItem);
column.Item().Element(mergedBlock).AlignCenter().Text(subHeaderValue);
}
}
);
}
}
}
else
{
table.Cell().RowSpan(maxListCount).Row(p => p.RelativeColumn().Column(
column =>
{
foreach (var value in list)
{
column.Item().Element(mergedBlock).AlignCenter().Text(value);
}
}));
}
}
else
{
if (maxListCount > 0)
{
table.Cell().RowSpan(maxListCount).Element(Block).Text(value?.ToString() ?? string.Empty);
}
else
{
table.Cell().Element(Block).Text(value?.ToString() ?? string.Empty);
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... e-a-report