Posted 21 October 2021, 6:20 pm 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();
Spread.Sheets[0].NamedStyles.Add(alternateRowStyle);
//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;
Thanks!