I load the main report and the subreport from * .jrxml and add a conditional style to the main report and the subreport. In the main work of the conditional style of the report, but in the subtitle, this is not so.
the code
public static JasperDesign getJasperDesign(InputStream isReport) throws JRException {
JasperDesign jasperDesign = JRXmlLoader.load(isReport);
JRDesignStyle jrDesignRootStyle = (JRDesignStyle) dynamicReportToJasperReportConverter.convertStyle(Template.rootStyle.getStyle());
jrDesignRootStyle.setName("rootStyle");
jasperDesign.addStyle(jrDesignRootStyle);
JRDesignStyle jrDesignStyle = (JRDesignStyle) dynamicReportToJasperReportConverter.convertStyle(Template.columnStyle.getStyle());
jrDesignStyle.setName("columnStyle");
jrDesignStyle.setParentStyle(jrDesignRootStyle);
JRDesignConditionalStyle jrDesignConditionalStyle = new JRDesignConditionalStyle();
JRDesignExpression conditionExpression = new JRDesignExpression();
conditionExpression.setValueClassName(String.valueOf(Boolean.class));
conditionExpression.setText("$V{REPORT_COUNT}%2 == 1");
jrDesignConditionalStyle.setConditionExpression(conditionExpression);
jrDesignConditionalStyle.setBackcolor(Template.valueColor2);
jrDesignStyle.addConditionalStyle(jrDesignConditionalStyle);
jasperDesign.addStyle(jrDesignStyle);
return jasperDesign;
}
In the figure you see the result and value REPORT_COUNT:

Java code where the report is generated.
JasperReport jasperSubReportIC = TemplateConfigurator.buildSubReport(isSubReportIC, subQueryTO);
return Template.getReport(reportParameters.getOutputType(),sheetNameInExcel)
.setTemplate(Template.reportTemplate)
.title(Template.createTitleHeader(reportName, dateText, bundle, reportContext, reportParameters))
.lastPageFooter(Template.createFooter(dateText, bundle))
.setParameter("subreportParameterTO", jasperSubReportTO)
.setParameter("subreportParameterIC", jasperSubReportIC)
.setParameter("subQueryTO", subQueryTO)
.setParameter("subQueryIC", subQueryIC)
.setParameter("CONTEXT", super.reportContext)
.setLocale(locale)
.setResourceBundle(bundle)
.setTemplateDesign(TemplateConfigurator.getJasperDesign(is))
.setDataSource(query, DatabaseConnection.getConnection())
.show()
.toJasperPrint();
JRXML code where an auxiliary report is implemented.
<subreport>
<reportElement x="0" y="0" width="802" height="49" uuid="50369a11-d831-4c54-b16f-95fbed8b5bba"/>
<subreportParameter name="REPORT_LOCALE">
<subreportParameterExpression><![CDATA[$P{REPORT_LOCALE}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="TO_ID">
<subreportParameterExpression><![CDATA[$F{TO_ID}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="REPORT_RESOURCE_BUNDLE">
<subreportParameterExpression><![CDATA[$P{REPORT_RESOURCE_BUNDLE}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[$P{dataScriplet_SCRIPTLET}.createDataSourceTO($P{REPORT_CONNECTION},$P{subQueryTO},$F{TO_ID})]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{subreportParameterTO}]]></subreportExpression>
</subreport>
source
share