Setting CellRange style having unintended effects

Greetings,



In part of my application, I’m setting the
background color of a range of cells a different color to indicate that
they are being used. ie Set A1:B3’s background to Red.



If I set the background color like this,



Dim redStyle as new Style

redStyle.Color = Color.Red

mySheet.SetStyle(myRange, redStyle)



This will set the background color to the range to red, but it will
remove any other formatting that the range may have. ie if A1’s
cell has centered text, and A2’s cell has right justified text, and B2
has a border around the edges, all that formatting will be removed when
I set the color in this manner. All the text will be left
justified and the borders removed.



Other than looping through and setting each GridCell Style in the
CellRange individually, is there any way to set the background color of
a cell range without modifying any of the other formattings of the
range?



Thanks,

Chris Powell


Hi Chris,

This feature is not supported currently. I will implement the feature right row. Maybe it needs 2 or 3 days.

Hi Chris,

I implemented the feature in v1.7.1.6 in attachment. You can try this code:

Worksheet sheet = gridDesktop1.Worksheets[0];
Style style = new Style(gridDesktop1);
style.Color = Color.Red;
style.SetBorderLine(BorderType.Left, BorderLineType.Thin);
style.SetBorderColor(BorderType.Left, Color.Blue);
CellRange range = sheet.CreateRange("a1", "b3");
StyleSet styleSet = StyleSet.Color;
styleSet |= StyleSet.Border;
sheet.SetStyle(range, style, styleSet);

The StyleSet enumeration provides some bit mask values indicating which properties applied to.

I fiexed the bug of ImportExcelFile with the runFormulas argument. When invoking RunAllFormulas method in debug mode, it will take a long time, if there are many formulas. I will fix this issue in future.

Greetings,



I implemented this change in our project
today. Everything seemed to work well. We continue testing
our application over the next day or two. I’ll let you know if we
run into anything else.



Thanks,

Chris Powell