How to Set a range's backgroundcolor?

hi, I use the following's code to set a range's backgroundcolor, but it dosen't work, could you please give me some point?

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;

//Create a named range
Range range = sheet.Cells.CreateRange("B1", "E5");
//Set the name of the named range
range.Name = "Range1";
Aspose.Cells.Style style = workbook.Styles[workbook.Styles.Add()];
style.BackgroundColor = System.Drawing.Color.LightBlue;
style.Pattern = BackgroundType.Solid;

StyleFlag styleFlag = new StyleFlag();
styleFlag.All = true;
range.ApplyStyle(style, styleFlag);

workbook.Save(Server.MapPath("dd.xlsx"), FileFormatType.Excel2007Xlsx);

thanks.

Hi,

Please change the line of code in your code segment:
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;

//Create a named range
Range range = sheet.Cells.CreateRange("B1", "E5");
//Set the name of the named range
range.Name = "Range1";
Aspose.Cells.Style style = workbook.Styles[workbook.Styles.Add()];
style.ForegroundColor = System.Drawing.Color.LightBlue;
style.Pattern = BackgroundType.Solid;

StyleFlag styleFlag = new StyleFlag();
styleFlag.All = true;
range.ApplyStyle(style, styleFlag);

workbook.Save(Server.MapPath("dd.xlsx"));

When you use Solid pattern type, the BackgroundColor will not be effected. When you use Solid pattern type, you should use ForegroundColor instead.

Thank you.