110,539
社区成员
发帖
与我相关
我的任务
分享
ICellStyle style = workbook.CreateCellStyle();
//设置单元格的样式:水平对齐居中,有边框
style.Alignment = HorizontalAlignment.CENTER;
style.VerticalAlignment = VerticalAlignment.TOP;
style.BorderBottom = CellBorderType.THIN;
style.BorderLeft = CellBorderType.THIN;
style.BorderRight = CellBorderType.THIN;
style.BorderTop = CellBorderType.THIN;
cell = row.CreateCell(0, CellType.STRING);
style.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.RED.index; //指定背景颜色
//将新的样式赋给单元格
cell.CellStyle = style;
//填值
cell.SetCellValue("ABCDE");
CellStyle.FillPattern = FillPatternType.SQUARES;
CellStyle.FillForegroundColor = CellStyle.FillBackgroundColor = HSSFColor.YELLOW.index;