需要的效果:
源码:
XSSFWorkbook workbook = new XSSFWorkbook();
ISheet sheet = workbook.CreateSheet("测试");
sheet.DefaultRowHeightInPoints = 19.5F;
//行1
IRow row = sheet.CreateRow(0);
//列1
ICell cell = row.CreateCell(0);
//列2
cell = row.CreateCell(1);
cell.SetCellValue("表头");
XSSFCellStyle style = (XSSFCellStyle)workbook.CreateCellStyle();
style.Alignment = HorizontalAlignment.Center;
style.VerticalAlignment = VerticalAlignment.Center;
style.SetFillForegroundColor(new XSSFColor(new byte[] { 2, 162, 116 }));
style.FillPattern = FillPattern.SolidForeground;
byte[] rgb = style.FillForegroundXSSFColor.ARGB;
Console.WriteLine(System.Drawing.Color.FromArgb(rgb[0], rgb[1], rgb[2], rgb[3]).ColorToString());
cell.CellStyle = style;
//行2
row = sheet.C