Thanks for your posting and using Aspose.Cells for .NET.
You need to set StyleFlag.All property to true or selectively set the properties for which you want to apply your style.
For example, if you want to change the fill color, you will have to set StyleFlag.CellShading = true .
And if you want to change the font color, you will have to set the StyleFlag.FontColor = true .
In order to illustrate this, I have written a code that sets the fill color and font color of first 10 rows. I have also attached the output file generated by the following code and screenshot for your reference.
Please download and use the latest version:
Aspose.Cells for .NET (Latest Version)
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets;
Random rand = new Random();
for (int i = 0; i < 10; i++)
//Random forground color, it will be a font color
int fred = rand.Next(255);
int fgreen = rand.Next(255);
int fblue = rand.Next(255);
//Random background color, it will be a fill color
int bred = rand.Next(255);
int bgreen = rand.Next(255);
int bblue = rand.Next(255);
//Create a style object to set font and fill color of the cell
Style style = workbook.CreateStyle();
style.Font.Color = Color.FromArgb(fred, fgreen, fblue);
style.Pattern = BackgroundType.Solid;
style.ForegroundColor = Color.FromArgb(bred, bgreen, bblue);
//CellShading means we want to change fill color
//FontColor means we also want to change font color
StyleFlag sf = new StyleFlag();
sf.CellShading = true;
sf.FontColor = true;
//Write some text in first cell of each row.