Free Support Forum - aspose.com

Cannot set background color for cell

Hi,

I am trying to set up set the background cell using the following

The font color changes to silver but the background color does not change.

Here is code

For i As Integer = 4 To 10

reportWS.Cells(4, i).Style.Font.IsBold = True

reportWS.Cells(4, i).Style.HorizontalAlignment = TextAlignmentType.Center

reportWS.Cells(4, i).Style.Font.Color = System.Drawing.Color.Silver

reportWS.Cells(4, i).Style.VerticalAlignment = TextAlignmentType.Center

reportWS.Cells(4, i).Style.

Next

Thanks in advance..

I change the code to the following

reportWS.Cells(4, i).Style.Font.IsBold = True

reportWS.Cells(4, i).Style.HorizontalAlignment = TextAlignmentType.Center

' reportWS.Cells(4, i).Style.Font.Color = System.Drawing.Color.Silver

reportWS.Cells(4, i).Style.VerticalAlignment = TextAlignmentType.Center

reportWS.Cells(4, i).Style.Pattern = BackgroundType.Solid

reportWS.Cells(4, i).Style.BackgroundColor = Color.Blue

It still does not work. But if i change BackgroundType to anything else e.g gray75 it shows the blue color.Please help

Thanks again..

parez81 wrote:

Hi,

I am trying to set up set the background cell using the following

The font color changes to silver but the background color does not change.

Here is code

For i As Integer = 4 To 10

reportWS.Cells(4, i).Style.Font.IsBold = True

reportWS.Cells(4, i).Style.HorizontalAlignment = TextAlignmentType.Center

reportWS.Cells(4, i).Style.Font.Color = System.Drawing.Color.Silver

reportWS.Cells(4, i).Style.VerticalAlignment = TextAlignmentType.Center

reportWS.Cells(4, i).Style.

Next

Thanks in advance..

Background color only takes effect when the pattern is not solid or none. Please set the foreground color:

reportWS.Cells(4, i).Style.ForegroundColor = Color.Blue