Set BackgroundColor using Aspose.Cells.Style

I am evaluating formatting functionality of Aspose.Cell component and created test application that imports object array to new Excel workbook and applies some formatting.

I created custom style and applied this style to cell and to the range of cells.

All style properties were applied except the background color. Am I doing something wrong?

Bellow are some of my code:

object[] objHeader = new object[1];

objHeader[0]=”Some Text”;

Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();

Aspose.Cells.Style myStyle = workbook.Styles[workbook.Styles.Add()];

myStyle.Font.Name="Arial";

myStyle.Font.Size=8;

myStyle.Font.IsBold=true;

myStyle.BackgroundColor=System.Drawing.Color.Red;

myStyle.Pattern=BackgroundType.Solid;

Aspose.Cells.Worksheet objSheet= workbook.Worksheets[workbook.Worksheets.Add()];

objSheet.Cells.Merge(0,0,1,10);

objSheet.Cells.ImportObjectArray(objHeader,0,0,false);

// this line will not change background color

workbook.Worksheets[objSheet.Name].Cells[0,0].Style= myStyle;


// this line will not change background color

workbook.Worksheets[objSheet.Name].Cells[10,0].Style= myStyle;


Aspose.Cells.Range myRangeTemp=
workbook.Worksheets[objSheet.Name].Cells.CreateRange(1,10,5,5);


// this line will not change background color

myRangeTemp.Style= myStyle;

//Code below will change a color of the cell

//workbook.Worksheets[objSheet.Name].Cells[0,0].Style.ForegroundColor=System.Drawing.Color.Blue;

//workbook.Worksheets[objSheet.Name].Cells[0,0].Style.Pattern=BackgroundType.Solid;

Thank You,

Aleksandra

Please change:

myStyle.BackgroundColor=System.Drawing.Color.Red;

to:

myStyle.ForegroundColor=System.Drawing.Color.Red;

Backgound color only takes effect when background pattern is not solid.

Thank you! After suggested modification my code was working.