You can not get data in subreport by only loading the main report into JasperReport
object. This object only contains the main report and it's elements.
The element relative to the subreport is a JRBaseSubreport, which has reference to data relative to subreport tag in main report, hence it does not contain the actual report object.
The subreport will be loaded by the filler depending on the expressions, you could actually load a different sub report depending on the values of your datasource so jasper report can't know what sub report to load until the report is filled.
But you can access the expression it will use to load the subreport and this maybe can be enough in your case
Example on how to access the expression (subreport in first detail band)
//I know the subreport is in first detail band so I access this directly
JRBaseBand detailBand1 = (JRBaseBand) report.getDetailSection().getBands()[0];
List<JRChild> elements = detailBand1.getChildren(); //Get all children
for (JRChild child : elements) {
if (child instanceof JRBaseSubreport){ //This is a subreport
JRBaseSubreport subreport = (JRBaseSubreport)child;
String expression= ""; //Lets find out the expression used
JRExpressionChunk[] chunks = subreport.getExpression().getChunks();
for (JRExpressionChunk c : chunks) {
expression +=c.getText();
}
System.out.println(expression);
//Here you could do code to load the subreport into a JasperReport object
}
}
With this data you can load the subreport manually into another JasperReport
object and access name, fields etc. Naturally if you have a complex expression your code will need to reflect this (retrive parameters or data from datasource)