zoukankan      html  css  js  c++  java
  • NPOI2.0学习(三)

    HSSFWorkbook wk = new HSSFWorkbook();//你用来操作的HSSFWorkbook的实例  
    ICellStyle cellStyle = wk.CreateCellStyle(); 
    ICellStyle cellStyle = wk.CreateCellStyle();  
    //设置单元格上下左右边框线  
    cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;  
    cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;  
    cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;  
    cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;  
    //文字水平和垂直对齐方式  
    cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;  
    cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;  
    //是否换行  
    //cellStyle.WrapText = true;  
    //缩小字体填充  
    cellStyle.ShrinkToFit = true; 
    
    
     ICellStyle style2 = wb.CreateCellStyle();//样式
        IFont font1 = wb.CreateFont();//字体
        font1.FontName = "楷体";
        font1.Color = HSSFColor.Red.Index;//字体颜色
        font1.Boldweight = (short)FontBoldWeight.Normal;//字体加粗样式
        style2.SetFont(font1);//样式里的字体设置具体的字体样式
        //设置背景色
        style2.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index;
        style2.FillPattern = FillPattern.SolidForeground;
        style2.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index;
        style2.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;//文字水平对齐方式
        style2.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;//文字垂直对齐方式
    ICell Cell = sheet.CreateRow(0).CreateCell(0);  
    Cell.CellStyle = cellStyle;  
    Cell.SetCellValue("测试格式效果");  
    ICellStyle newCellStyle = wk.CreateCellStyle();  
    newCellStyle.CloneStyleFrom(cellStyle);  
    newCellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left; 
  • 相关阅读:
    2014 HDU多校弟九场I题 不会DP也能水出来的简单DP题
    POJ 2208 Pyramids 欧拉四面体
    BNU 4067 求圆并
    POJ 3675 Telescope 简单多边形和圆的面积交
    POJ 2451 Uyuw's Concert(半平面交nlgn)
    [置顶] 程序员期望月薪那些事儿
    一、转正的那些事儿
    鼓膜内陷(听别人说话还震动)
    程序员的职场潜意识Top10
    年过40岁的雷军致已逝去的青春!
  • 原文地址:https://www.cnblogs.com/shy1766IT/p/5357670.html
Copyright © 2011-2022 走看看