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

Free Support Forum - aspose.com

BackgroundType.Solid not working for cel background color

Hello
I am using aspose version 4.8.2.3. I use the below code to set the background color of a cell

objLicense.SetLicense(sLicUrl);

Workbook workbook = new Workbook();

//Get the first worksheet in the workbook

Worksheet sheet = workbook.Worksheets[0];

sheet.Cells["A1"].PutValue("Footnote Assignments");

Aspose.Cells.Style style = sheet.Cells["A1"].GetStyle();

//Setting the foreground color to yellow

style.BackgroundColor = Color.Yellow;

//Setting the background pattern to Solid

style.Pattern = BackgroundType.Solid;

//Apply the style to A1 cell

sheet.Cells["A1"].SetStyle(style);

sheet.AutoFitColumns();

workbook.Save("FootNoteTemplate.xls", FileFormatType.Excel97To2003, SaveType.OpenInExcel, this.Response);

// End response to avoid unneeded html after xls

Response.End();

But when the excel generate there is no back ground color for cell "A1". COlor appears if i select other BackgroundType like gray 75,25 or HorizontalStripe or something else. But i have to use the style Solid

Thanks

Sourav

Hi,

Well, The BackgroundColor would not be applied if you specify Pattern type to Solid or None. I think for your need, either you may change the Pattern to other than Solid or None, Or, you may simply use ForegroundColor attribute instead.

//Setting the foreground color to yellow

style.ForegroundColor = Color.Yellow;

//Setting the background pattern to Solid

style.Pattern = BackgroundType.Solid;


it will work fine.


For further reference, see the topic:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/colors-background-patterns.html
and read the Note there, I will quote here, i.e. "Note: If you select BackgroundType.None value from the BackgroundType enumeration, forground color will not be applied whereas background color is not applied if you select BackgroundType.None or BackgroundType.Solid value."

Thanks.

Hi.

It works. Thank you a lot for the help.

Thanks

Sourav