DataTerrain Logo DataTerrain Logo DataTerrain Logo
  • Home
  • Why DataTerrain
  • Reports Conversion
  • Talent Acquisition
  • Services
    • ETL SolutionsETL Solutions
    • Performed multiple ETL pipeline building and integrations.

    • Oracle HCM Cloud Service MenuOracle HCM Analytics
    • 9 years of building Oracle HCM fusion analytics & reporting experience.

    • Data Lake IconData Lake
    • Experienced in building Data Lakes with Billions of records.

    • BI Products MenuBI products
    • Successfully delivered multiple BI product-based projects.

    • Legacy Scripts MenuLegacy scripts
    • Successfully transitioned legacy scripts from Mainframes to Cloud.

    • AI/ML Solutions MenuAI ML Consulting
    • Expertise in building innovative AI/ML-based projects.

  • Resources
    • Oracle HCM Tool
      Tools
    • Designed to facilitate data analysis and reporting processes.

    • HCM Cloud Analytics
      Latest News
    • Explore the Latest Tech News and Innovations Today.

    • Oracle HCM Cloud reporting tools
      Blogs
    • Practical articles with Proven Productivity Tips.

    • Oracle HCM Cloud reporting
      Videos
    • Watch the engaging and Informative Video Resources.

    • HCM Reporting tool
      Customer Stories
    • A journey that begins with your goals and ends with great outcomes.

    • Oracle Analytics tool
      Careers
    • Your career is a journey. Cherish the journey, and celebrate the wins.

  • Contact Us
  • Blogs
  • BI Insights Hub
  • How to Create Alternate Row Background Color in Jaspersoft Reports
  • 11 Oct 2024

How to Create Alternate Row Background Color in Jaspersoft Reports

Alternate Row Background in Jaspersoft
  • Share Post:
  • LinkedIn Icon
  • Twitter Icon

In Jaspersoft reports, alternating row background colors are a common requirement to improve readability. This can be achieved using conditional styles in combination with Jaspersoft's built-in variables, which track the current row position during the report-filling process.

The detail section in a report is responsible for displaying the records from a dataset. Since it repeats for each record, adding alternate row colors helps distinguish between rows and provides a clearer visual representation, especially in table layouts.

Implement alternate row colors in Jaspersoft using conditional styles and built-in counting variables.

Steps to Implement Alternate Row Background Colors:

To achieve alternating row colors, you need to:

1. Determine the Current Record Number: This is done using Jaspersoft’s built-in counting variables, such as:

  • REPORT_COUNT: Tracks the current record count for the entire report. Use this if the row color alternation should be consistent across the entire report, unaffected by page breaks.
  • PAGE_COUNT: Resets the count for each new page, ensuring the same row color starts on each page.
  • COLUMN_COUNT: Resets the count for each new page column.
  • GROUP_COUNT: Resets the count for each new group of records, starting with the same row color for each group.
  • ROW_COUNT: For crosstab reports, this variable returns the current row number in the crosstab.

2. Set Up Conditional Styles: Conditional styles consist of a Boolean condition and a style definition. The style is applied only if the condition evaluates to true.

Example: Applying Alternate Row Background Color

Here’s an example of how to create a conditional style that alternates row background colors between blue and red.

XML
Copy code

                                    <style name="defaultRowStyle" fontName="Arial">
                                       <conditionalStyle>
                                          <conditionExpression><![CDATA[$V{REPORT_COUNT} % 2 == 0]]></conditionExpression>
                                          <style backcolor="blue"/>
                                       </conditionalStyle>
                                       <conditionalStyle>
                                          <conditionExpression><![CDATA[$V{REPORT_COUNT} % 2 != 0]]></conditionExpression>
                                          <style backcolor="red"/>
                                       </conditionalStyle>
                                    </style>
                                    

In this code:

  • The condition expression ($V{REPORT_COUNT} % 2 == 0) checks if the current row number is even. If it is, the row’s background color is set to blue.
  • The second condition applies the red background color to odd-numbered rows.

Applying the Style in Jaspersoft Studio:

1. Open your report in Jaspersoft Studio.

2. Select the Detail band where the records are displayed.

3. In the Style Properties section, create a new style and add the conditional logic shown in the XML above.

4. Apply the style to the elements in your detail section (e.g., text fields, background elements).

Advanced Considerations:

  • Grouped Data: If your report contains grouped data, you can use the _COUNT variable to apply alternating colors based on each group’s starting point.
  • Performance: Be mindful of performance when applying complex styles to large datasets. Conditional styles add processing overhead, particularly for large reports.

For more detailed information on using conditional styles, refer to Jaspersoft’s official documentation.

Conclusion

Enhance the effectiveness of your Jaspersoft reports with Data Terrain's expertise. Our team specializes in optimizing reporting solutions, ensuring your educational and business insights are both visually engaging and easy to understand. With over a decade of experience, we help organizations implement and customize advanced features like alternate row background colors and more, tailored to your specific needs.

Categories
  • All
  • BI Insights Hub
  • Data Analytics
  • ETL Tools
  • Oracle HCM Insights
  • Legacy Reports conversion
  • AI and ML Hub

Ready to initiate your BI Migration Journey?

Start Now
Customer Stories
  • All
  • Data Analytics
  • Reports conversion
  • Jaspersoft
  • Oracle HCM
Recent posts
  • how-to-create-alternate-row-backgroundcolor-in-jaspersoft-reports-01
    How to Create Alternate Row Background...
  • pluggable-custom-visualizations-in-jaspersoft-01
    Pluggable Custom Visualizations in...
  • jaspersoft-report-built-in-charts-01
    Jaspersoft Report Built-in Charts...
  • jaspersoft-report-creation-phases-01
    Jaspersoft Report Creation Phases: A...
  • charting-functionality-in-jaspersoft-01
    Charting Functionality in Jaspersoft...
  • auditing-monitoring-in-jaspersoft-01
    Auditing & Monitoring in Jaspersoft
  • overview-of-security-features-in-jaspersoft-reports-server-01
    Security Features in Jaspersoft Reports
  • jaspersoft-built-in-system-parameters-01
    Jaspersoft Built-in System Parameters
  • microsoft-power-bi-vs-ibm-cognos-analytics-comparison-01
    IBM Cognos vs Power BI: A Comprehensive
  • jaspersoft-vs-power-bi-comparison-01
    Jaspersoft Vs. Power BI: A Comprehensive
  • microsoft-power-bi-vs-tableau-comparison-01
    Tableau vs. Power BI: A Comprehensive
  • jaspersoft-reporting-with-json-javascript-object-notation-datasource-01
    Jaspersoft Reporting with JSON...
  • jasper-reports-global-scriptlets-01
    JasperReports Global Scriptlets: Enhancing
  • microsoft-power-bi-vs-sap-crystal-comparison-01
    Microsoft Power BI vs SAP Crystal Reports
  • an-overview-of-jasper-reports-scriptlet-class-01
    An Overview of JasperReports Scriptlet Class
  • steps-to-integrate-jaspersoft-studio-with-server-01
    Integrating Jaspersoft Studio with Jaspersoft..
  • understanding-jasper-reports-in-java-01
    Jasper Reports in Java: Expert Guide to..
  • exploring-alteryx-designer-a-comprehensive-solution-for-etl-processes-01
    Exploring Alteryx Designer: A
  • understanding-microsoft-fabric-and-its-etl-migration-capabilities-01
    Understanding Microsoft Fabric and Its ETL
Connect with Us
  • About
  • Careers
  • Privacy Policy
  • Terms and condtions
Sources
  • Customer stories
  • Blogs
  • Tools
  • News
  • Videos
  • Events
Services
  • Reports Conversion
  • ETL Solutions
  • Data Lake
  • Legacy Scripts
  • Oracle HCM Analytics
  • BI Products
  • AI ML Consulting
  • Data Analytics
Get in touch
  • connect@dataterrain.com
  • +1 650-701-1100

Subscribe to newsletter

Enter your email address for receiving valuable newsletters.

logo

© 2025 Copyright by DataTerrain Inc.

  • twitter