XSSFCellStyle headStyle = workBook.CreateCellStyle() as XSSFCellStyle; headStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; XSSFFont font = workBook.CreateFont() as XSSFFont; font.FontHeightInPoints = 10; font.Boldweight = 700; font.Color = IndexedColors.Red.Index; headStyle.SetFont(font); IRow gapRow = sheet.CreateRow(lineCount); gapRow.CreateCell(3 + i).SetCellValue(line4[i]); if (line4[i] != 0) { gapRow.GetCell(3 + i).CellStyle = headStyle; }
主要问题是两个as不能省。
标签:headStyle,格子,样式,line4,NPOI,gapRow,XSSFFont,font From: https://www.cnblogs.com/wonder223/p/18416618