代码:
class="code_img_closed" src="/Upload/Images/2017081011/0015B68B3C38AA5B.gif" alt="" />logs_code_hide('ddcfbe49-7624-483b-95a1-4676cacd5482',event)" src="/Upload/Images/2017081011/2B1B950FA3DF188F.gif" alt="" />ICellStyle cellStyle = workbook.CreateCellStyle(); cellStyle.BorderBottom = BorderStyle.Thin; cellStyle.BorderLeft = BorderStyle.Thin; cellStyle.BorderRight = BorderStyle.Thin; cellStyle.BorderTop = BorderStyle.Thin; cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; ICellStyle cellStyleTitle = workbook.CreateCellStyle(); cellStyleTitle.BorderBottom = BorderStyle.Thin; cellStyleTitle.BorderLeft = BorderStyle.Thin; cellStyleTitle.BorderRight = BorderStyle.Thin; cellStyleTitle.BorderTop = BorderStyle.Thin; cellStyleTitle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; cellStyleTitle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; IFont font = workbook.CreateFont(); font.IsBold = false; font.FontHeightInPoints = 12; cellStyleTitle.SetFont(font); HSSFPalette palette = ((HSSFWorkbook)workbook).GetCustomPalette(); palette.SetColorAtIndex((short)9, 98, 185, 106); var color = palette.FindColor(98, 185, 106); //下面两行设置单元格背景色 cellStyleTitle.FillPattern = FillPattern.SolidForeground; cellStyleTitle.FillForegroundColor = color.Indexed; ICellStyle cellStyleTitle2 = workbook.CreateCellStyle(); cellStyleTitle2.CloneStyleFrom(cellStyleTitle); font = workbook.CreateFont(); font.IsBold = false; font.FontHeightInPoints = 14; cellStyleTitle2.SetFont(font);View Code