ClosedXML.Report
ClosedXML.Report copied to clipboard
The range does not meet the requirements of the list ranges.
Howdy,
I'm thick. About a year ago I looked into ClosedXML.Report for report generation, and got regular tables and nested tables to work as expected. I'm revisiting to create a new report, but am just coming across the title's issue.
I have a Parent class that has multiple Objects, which have multiple Items. Parent, Parent_Object, Parent_Object_Items.
Here is the template: HardwareGroupSchedule.xlsx
The thing I notice the most is that I have 3 blank rows (1, 2, 3) on the top in the template, and one blank row (6) within the nested range. When the report generates, it loses one of those top rows, and the blank row in the range (see below)

Please tell me I'm missing something simple here.
Thanks
Just this week I was creating a new report and ran into the same thing. If I create a new template, or copy an existing file and then modify it I get the same error. I am wondering if it is due to an office update.
My existing templates seem to still work, just not any new ones.
Need help figuring this out.
Thanks, Jay
Attach your template please
Hey b0bi79, refer to the initial post for the template.
Without knowledge of the data structure it is hard to invastigate what is wrong, but if I presume Parent
is a single entity (not a collection) then you don't need to create a named range for it. Then, for accesing parent's properties you don't need to use item
in cell B4. And named ranges for Objects
and Objects_Items
must not be prefixed with Parent
.
Here is a sample code I came up with, and the fixed template is attached. It may not math exactly to what you expected but may serve as a starting point.
var templateModel = new
{
ParentName = "parent name",
Objects = new[]
{
new
{
Name1 = "Name 1",
Name2 = "Name 2",
Items = new[]
{
new
{
Qty1 = 1,
ReportName1 = "n1",
FullName1 = "alex",
Qty2 = 100,
ReportName2 = "n2",
FullName2 = "pankraty"
}
}
},
}
};
var template = new XLTemplate("HardwareGroupSchedule.xlsx");
template.AddVariable(templateModel);
template.Generate();
template.SaveAs(...);