Highlighting Even Rows in Reports (Zebra Striping)

2013-03-27

We often use zebra striping of table data for easy viewing the reports. Highlighting even rows is good for viewing but they look strange on paper or in Excel table.  FastReport users have two methods for using highlighting only in preview window.

Method #1

You need to open report in the Designer and open the Style Editor from Report-Styles menu. Then we add a style with name "EvenRows" and set needed background color for even lines.  Then you need to set a band property EvenStyle = EvenRows.

You need to add the parameter in the Parameters item of Data Tree with name "EvenOff", bool type end default expression "false". Then let to add new event handler of Report in object inspector. Double-click on StartReport event and write code:

private void _StartReport(object sender, EventArgs e)
    {
       if ((Boolean)Report.GetParameterValue("EvenOff"))
        Data1.EvenStyle = "";
      else
        Data1.EvenStyle = "EvenRows";
    }

Now you can control highlighting from code.

Review an example for export in Excel from WebReport:

...
            webReport.Report.SetParameterValue("EvenOff", true);
            webReport.Report.Prepare();

            Stream stream = new MemoryStream();

            webReport.Report.Export(new Excel2007Export(), stream);

...

 

Method #2

All objects in report have properties Printable and Exportable. These properties set in true by default and enable or disable object in print or export. You can create an empty text object and set needed properties. Then you need to set a style as described above and put object behind the striped objects. To do this, right click on the object and select the bottom menu item "Send To Back". Remember that striped objects should have a transparent background.


.NET .NET FastReport FastReport
April 22, 2025

Working with the TfrShellTreeView Component in FastReport VCL

In this article, we will look at the TfrShellTreeView component. It is designed to display file system elements and is partially analogous to the TDirectoryListBox, TDirectoryOutline, and TShellTreeView components.
April 21, 2025

How RFID Tags Work in FastReport VCL

In this article, we'll check out how RFID tags work with the new TfrxDeviceCommand object in FastReport VCL with release 2025.2.
April 08, 2025

How to Set Up a Connection to Apache Ignite in FastReport .NET

In this article, we will explore how to configure a connection to Apache Ignite in FastReport .NET. You will learn the necessary steps to connect the plugin via code and the report designer.
Fast Reports
  • 800-985-8986 (English, US)
  • +31 97 01025-8466 (English, EU)
  • +49 30 56837-3928 (German, DE)
  • +55 19 98147-8148 (Portuguese, BR)
  • info@fast-report.com
  • 66 Canal Center Plaza, Ste 505, Alexandria, VA 22314

© 1998-2025 Fast Reports Inc.