IFont font = hssfworkbook.CreateFont();//创建字体对象
ICellStyle style1 = hssfworkbook.CreateCellStyle();
style1.Alignment = NPOI.SS.UserModel.HorizontalAlignment.CENTER;
style1.SetFont(font);
style1.FillPattern = FillPatternType.SOLID_FOREGROUND;
font.FontName = "宋体";
font.FontHeightInPoints = 9;
font.Boldweight = (short)FontBoldWeight.BOLD;
for (int u = 0; u < table.Rows.Count; u++)
{
IRow row2 = sheet1.CreateRow(hang); ICell cell2 = row2.CreateCell(0);
dibu(row2, cell2, hssfworkbook, sheet1, 0, table.Rows[u][2].ToString(), style1);
dibu(row2, cell2, hssfworkbook, sheet1, 1, table.Rows[u][3].ToString(), style1);
dibu(row2, cell2, hssfworkbook, sheet1, 2, table.Rows[u][4].ToString(), style1);
dibu(row2, cell2, hssfworkbook, sheet1, 3, table.Rows[u][6].ToString(), style1);
dibu(row2, cell2, hssfworkbook, sheet1, 4, table.Rows[u][5].ToString(), style1);
hang = hang
public void dibu(IRow row, ICell cell, HSSFWorkbook hb, ISheet ish, int lie, string a, ICellStyle style1)
{
cell = row.CreateCell(lie);
//设置单元格内容
cell.SetCellValue(a);
cell.CellStyle = style1;
}
我没设置背景。。但是不知道为什么变成了黑色
你没设置背景,那么请问这一句是哪个人写的,叫他出来。
style1.FillPattern = FillPatternType.SOLID_FOREGROUND;
...
...
cell.CellStyle = style1
大哥我错了 ,你宰了我吧。。
结贴给分 万分感谢
Excel 单元格还能“透明”?啥意思?