using System; using System.Text; using System.IO; using NPOI.HSSF.UserModel; using NPOI.HPSF; using NPOI.POIFS.FileSystem; using NPOI.SS.UserModel; namespace FillBackgroundInXls { class Program { static void Main(string[] args) { InitializeWorkbook(); Sheet sheet1 = hssfworkbook.CreateSheet("Sheet1"); //fill background CellStyle style1 = hssfworkbook.CreateCellStyle(); style1.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.BLUE.index; style1.FillPattern = FillPatternType.BIG_SPOTS; style1.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.PINK.index; sheet1.CreateRow(0).CreateCell(0).CellStyle = style1; //fill background CellStyle style2 = hssfworkbook.CreateCellStyle(); style2.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.YELLOW.index; style2.FillPattern = FillPatternType.ALT_BARS; style2.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.ROSE.index; sheet1.CreateRow(1).CreateCell(0).CellStyle = style2; //fill background CellStyle style3 = hssfworkbook.CreateCellStyle(); style3.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LIME.index; style3.FillPattern = FillPatternType.LESS_DOTS; style3.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.LIGHT_GREEN.index; sheet1.CreateRow(2).CreateCell(0).CellStyle = style3; //fill background CellStyle style4 = hssfworkbook.CreateCellStyle(); style4.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.YELLOW.index; style4.FillPattern = FillPatternType.LEAST_DOTS; style4.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.ROSE.index; sheet1.CreateRow(3).CreateCell(0).CellStyle = style4; //fill background