NPOI设定某个格子的样式

                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不能省。

posted @ 2024-09-16 21:26  老飞飞  阅读(15)  评论(0编辑  收藏  举报