使用
在線顏色選擇器 | RGB顏色查詢對照表
(http://tools.jb51.net/static/colorpicker/)
查找顏色RGB
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.CreateSheet("計划") as HSSFSheet;
//調色板實例
HSSFPalette palette = workbook.GetCustomPalette();
palette.SetColorAtIndex((short)10, (byte)228, (byte)223, (byte)236);
HSSFColor hssFColor = palette.FindColor((byte)228, (byte)223, (byte)236);
第一個參數:設置調色板新增顏色的編號,自已設置即可;取值范圍8-64
第二、第三、第四個參數,組成RGB值
ICellStyle title_style = workbook.CreateCellStyle();
//設置單元格上下左右邊框線
title_style.BorderTop = BorderStyle.Thin;
title_style.BorderBottom = BorderStyle.Thin;
title_style.BorderLeft = BorderStyle.Thin;
title_style.BorderRight = BorderStyle.Thin;
title_style.WrapText = true;
title_style.Alignment = HorizontalAlignment.Left;
title_style.VerticalAlignment = VerticalAlignment.Center;
title_style.FillPattern = FillPattern.SolidForeground;
title_style.FillForegroundColor = hssFColor.GetIndex();
HSSFRow dataRow2 = sheet.CreateRow(1) as HSSFRow;
for (int i = 0; i < det_title_arr.Length; i++)
{
ICell Cell = dataRow2.CreateCell(i);
Cell.CellStyle = title_style;
}
參考:https://www.cnblogs.com/yxhblog/p/6225018.html
