We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Cells set background color problem in export to excel

Hi,

I have problem to set background color in first row of excel file. The code what is not working is below:

Dim newStyle As Aspose.Cells.Style = cells.Rows(0).Style
newStyle.Font.IsBold = True
newStyle.BackgroundColor = Color.Red
Dim styleFlag As StyleFlag = New StyleFlag()
styleFlag.All = True
cells.Rows(0).ApplyStyle(newStyle, styleFlag)Dim newStyle As Aspose.Cells.Style = cells.Rows(0).Style
newStyle.Font.IsBold = True
newStyle.BackgroundColor = Color.Red
Dim styleFlag As StyleFlag = New StyleFlag()
styleFlag.All = True
cells.Rows(0).ApplyStyle(newStyle, styleFlag)

In this case only 'IsBold' properties is working. Can anybody help what I'm doing wrong?

Hi,


Please change your line of code:
i.e.,
newStyle.BackgroundColor = Color.Red

with:
newStyle.ForegroundColor = Color.Red
newStyle.Pattern = BackgroundType.Solid


Thank you.


Thanks, it works!

Hi,


Good to know that it works for you now. Feel free to contact us any time if you find any other issue or queries, we will be happy to assist you soon.

Thank you.