Set Sheet Alternating Row Style

Posted by: nathan.hanson on 21 October 2021, 9:20 am EST

  • Posted 21 October 2021, 9:20 am EST

    I have set up a StyleInfo object and set its background to AliceBlue. I would like to apply it to every other row of my ActiveSheet. It’s expensive to loop through all of the rows and set the StyleName for each one. Is there a faster way? Here’s some sample code:

                // Set up our althernating row style
                StyleInfo alternateRowStyle = new StyleInfo();
                alternateRowStyle.Name = "alt";
                alternateRowStyle.FontSize = 13;
                alternateRowStyle.Background = Brushes.AliceBlue;
                Spread.Sheets[0].NamedStyles = new StyleInfoCollection();
                //Applying the style this way seems expensive. Is there a better way?
                for (int i = 1; i < Spread.Sheets[0].RowCount; i += 2)
                    Spread.Sheets[0].Rows[i].StyleName = alternateRowStyle.Name;


  • Posted 21 October 2021, 4:28 pm EST


    Sorry, but there is no direct way to set alternative-row-color in Spread for WPF.

    However, we can do the same in WinForms.


  • Posted 22 October 2021, 2:29 am EST

    Thank you for the response. We’re moving away from WinForms to adopt WPF, so I guess I’ll just keep using my for loop to set every other row style. Thanks!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels