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

Free Support Forum - aspose.com

Background colour

Why is this code setting the background colour red?

Dim Style As Aspose.Cells.Style = sheet.Cells(cColumnForLifeUsed & Row).GetStyle()

Style.ForegroundColor = System.Drawing.Color.Red
Style.Pattern = BackgroundType.Solid

sheet.Cells(cColumnForLifeUsed & Row).SetStyle(Style)


I am using Cells for .net, current version.

Many thanks

Richard

Hi,

This is the right way to set the background color. Foreground and background colors are actually used when pattern is gradient that needs two color. When you use pattern solid, then you don’t need second color, so only foreground color is used.

If you want to set the font color then you should use the Font property of Style.

Hi,

Moreover, I think you might be mixing the two things foreground and background. I think you are taking foreground color as font text color or something like that, that is not like it. And, you are thinking of background color as cell shading color. For your info, Foreground color is the cell's outline color and Background color is the back color of the cell actually. But, mind you, if you want to set a solid shading color for cells, you should use Foreground color with Solid pattern type. There is no need to use or count for Background color.

Hope, this helps,

Also, please check the topic for further reference:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/colors-background-patterns.html

Thank you.