Hi
Consider the following situation:
Multiple companies have multiple employees. We want to show a simple report:
Company A:
- employee 1 name, address, etc
- employee 2 name, address, etc
...
Company B:
...
Company C:
...
We must use xlsx to use nested bands. We’re also using pure java and json to construct the report.
This is the fragment of report construction:
ReportBand employeesBand = bandBuilder.name("Employees")
.orientation(BandOrientation.HORIZONTAL)
.query("Employees", "parameter=Employees $.Companies[@].Employees", "json")
.build();
ReportBand companiesBand = bandBuilder.name("Companies")
.orientation(BandOrientation.HORIZONTAL)
.query("Companies", "parameter=Companies $.Companies", "json")
.child(employeesBand)
.build();
reportBuilder.band(companiesBand);
// ...
reportParams.put("Companies", companiesJson);
The json looks like this:
{
"Companies":[
{
"Employees":[
{
"number":678,
"percent":50.0,
"employeeName":"John Doe"
}
],
"companyName":"A"
},
{
"Employees":[
{
"number":123,
"percent":65.0,
"employeeName":"Richard Roe"
},
{
"number":456,
"percent":45.0,
"employeeName":"John Cleese"
}
],
"companyName":"B"
},
{
"Employees":[
],
"companyName":"C"
}
]
}
The problem and question:
I can generate a report with companies showing correctly, but I cannot get the employees to show. What should be the JsonPath query for a nested child? Or maybe the problem is in the java code. I think the xlsx is prepared correctly, with correct named ranges.
I suppose the $.Companies[@].Employees
is wrong. Is it possible at all with json? Something like $.parentBand.Employees
?