Formatting Cells with fore ground color



I am facing problem while formatting cells with foreground color.I want to assign light yellow color to some columns.I am using below code to format cell ,it is showing black color.

cells.Columns(8).Style.ForegroundColor = Color.LightYellow

Pls find the attached excel.Those color i need .




LightYellow is not in default color palette. Please check for more information.

So please change your code to:

excel.ChangePalette(Color.LightYellow, 55)

cells.Columns(8).Style.ForegroundColor = Color.LightYellow

cells.Columns(8).Style.Pattern = BackgroundType.Solid



Your code is not yet all working,it is showing black color on the column.




Please try the following sample code and check the attached output file.

Dim excelObj As Excel = New Excel()

excelObj.ChangePalette(Color.LightYellow, 55)

Dim cells As Cells = excelObj.Worksheets(0).Cells

Cells.Columns(8).Style.ForegroundColor = Color.LightYellow

Cells.Columns(8).Style.Pattern = BackgroundType.Solid




Your code is working fine.But when I have written below code in function and calling that function for each cells with a particular condition.It is giving black color.

pls find the attachment those colors i want for my coloumn and rows.I could able to get lightyellow,it is showing different yellow color.

Can you please help to find out the solution.

cells.Item(intRowCounter, 2).Style = SetGoldColorHeader(excel)

Function SetGoldColorHeader(ByVal excel As Excel) As Style

Dim styles As styles = excel.Styles

Dim styleIndex As Integer = styles.Add()

Dim style As Aspose.Excel.Style = styles(styleIndex)

style.Font.Size = 10

style.Font.Color = Color.Black

style.Font.IsBold = True

style.Font.Name = "Arial"

style.IsTextWrapped = True

style.IndentLevel = 0

style.Borders(BorderType.BottomBorder).LineStyle = CellBorderType.Thick

style.Borders(BorderType.TopBorder).LineStyle = CellBorderType.Thin

style.Borders(BorderType.LeftBorder).LineStyle = CellBorderType.Thin

style.Borders(BorderType.RightBorder).LineStyle = CellBorderType.Thin

style.HorizontalAlignment = TextAlignmentType.Center

style.VerticalAlignment = TextAlignmentType.Bottom

excel.ChangePalette(Color.Gold, 55)

style.ForegroundColor = Color.Gold

style.Pattern = BackgroundType.Solid

Return style

End Function




Please try to change this line code:

excel.ChangePalette(Color.Gold, 55)


excel.ChangePalette(Color.Gold, 54)

And you can try this attached fix with the following code:

style.VerticalAlignment = TextAlignmentType.Bottom

style.ForegroundColor = excel.GetMatchingColor(Color.Gold)

style.Pattern = BackgroundType.Solid