Alternating row color for JasperReports

拈花ヽ惹草 提交于 2019-12-02 20:44:43
travega

Yes you can set up a style inside the JRXML file like this:

<style name="Zebra" mode="Transparent">
    <conditionalStyle>
        <conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 1]]></conditionExpression>
        <style backcolor="#CAC5BB"/>
    </conditionalStyle>
</style>

and add it to your report elements like this:

<reportElement style="Zebra" mode="Opaque" x="1" y="1" width="554" height="20"/>

You cannot add conditional styles to style template files (e.g., .jrtx files).

If you are not using "styles", you can have a static text field (with no text) or a rectangle with the background color that you need, overlapping the textfield with data and set the printWhenExpression to $V{report_COUNT}%2 == 1 OR $V{report_COUNT}%2 == 0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!