Dear All,
I need to set background color to specific row?
for example:
I need to set background color to red for rows: 3,10
please help
Thanks & Regards
Win
Hi,
Thanks for your posting and using Aspose.Cells.
Please see the following sample code and check the output excel file attached with this post for your reference.
C#
//Create workbook
Workbook workbook = new Workbook();
//Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];
//Create styke object
Style st = workbook.CreateStyle();
st.Pattern = BackgroundType.Solid;
st.ForegroundColor = Color.Red;
//Create style flag
StyleFlag flag = new StyleFlag();
flag.CellShading = true;
//Apply colors to rows
//3rd row
worksheet.Cells.Rows[2].ApplyStyle(st, flag);
//10th row
worksheet.Cells.Rows[9].ApplyStyle(st, flag);
//Save the workbook
workbook.Save(“output.xlsx”);