Hi, I am using HSSFWorkbook to generate report in Excel. I am trying to set background color of title but it is showing only black background.
My code is as
IWorkbook wb = new HSSFWorkbook();
ICellStyle style = wb.CreateCellStyle();
style.BorderBottom = BorderStyle.Thin;
style.BorderTop = BorderStyle.Thin;
style.BorderLeft = BorderStyle.Thin;
style.BorderRight = BorderStyle.Thin;
style.FillBackgroundColor = HSSFColor.LightGreen.Index;
style.FillPattern = FillPattern.SolidForeground;
ICellStyle hstyle = wb.CreateCellStyle();
hstyle.BorderBottom = BorderStyle.Thin;
hstyle.BorderTop = BorderStyle.Thin;
hstyle.BorderLeft = BorderStyle.Thin;
hstyle.BorderRight = BorderStyle.Thin;
hstyle.Alignment = HorizontalAlignment.Center;
IFont bfont = wb.CreateFont();
bfont.Boldweight = (short)FontBoldWeight.Bold;
hstyle.SetFont(bfont);
hstyle.FillBackgroundColor = HSSFColor.LightGreen.Index;
hstyle.FillPattern = FillPattern.SolidForeground;
ICellStyle datestyle = wb.CreateCellStyle();
datestyle.BorderBottom = BorderStyle.Thin;
datestyle.BorderTop = BorderStyle.Thin;
datestyle.BorderLeft = BorderStyle.Thin;
datestyle.BorderRight = BorderStyle.Thin;
datestyle.DataFormat = wb.CreateDataFormat().GetFormat("MMMM dd, yyyy");
datestyle.FillBackgroundColor = HSSFColor.LightGreen.Index;
datestyle.FillPattern = FillPattern.SolidForeground;
ICellStyle Titlestyle = wb.CreateCellStyle();
Titlestyle.BorderBottom = BorderStyle.Thin;
Titlestyle.BorderTop = BorderStyle.Thin;
Titlestyle.BorderLeft = BorderStyle.Thin;
Titlestyle.BorderRight = BorderStyle.Thin;
Titlestyle.Alignment = HorizontalAlignment.Center;
Titlestyle.SetFont(bfont);
Titlestyle.FillBackgroundColor = HSSFColor.Green.Index;
Titlestyle.FillPattern = FillPattern.SolidForeground;
ISheet sheet = wb.CreateSheet("Orders");
IRow row = sheet.CreateRow(0);
AddStyledCell(row, 0, Titlestyle).SetCellValue(ReportTitle);
sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0, 0, 0, 15));
Thanks