Package org.apache.poi.xssf.usermodel

Examples of org.apache.poi.xssf.usermodel.XSSFFont


        out.close();
    }

  private void initialize() {
    //CTFont ctFont = createDefaultFont();
    XSSFFont xssfFont = createDefaultFont();
    fonts.add(xssfFont);

    CTFill[] ctFill = createDefaultFills();
    fills.add(new XSSFCellFill(ctFill[0]));
    fills.add(new XSSFCellFill(ctFill[1]));
View Full Code Here


    return ctFill;
  }

  private static XSSFFont createDefaultFont() {
    CTFont ctFont = CTFont.Factory.newInstance();
    XSSFFont xssfFont=new XSSFFont(ctFont, 0);
    xssfFont.setFontHeightInPoints(XSSFFont.DEFAULT_FONT_SIZE);
    xssfFont.setColor(XSSFFont.DEFAULT_FONT_COLOR);//setTheme
    xssfFont.setFontName(XSSFFont.DEFAULT_FONT_NAME);
    xssfFont.setFamily(FontFamily.SWISS);
    xssfFont.setScheme(FontScheme.MINOR);
    return xssfFont;
  }
View Full Code Here

    sheet.setColumnWidth(7, 20*255)
    sheet.setColumnWidth(8, 10*255);   
    //创建第一行
    XSSFRow row=sheet.createRow(0);
    //表头样式
        XSSFFont fonttitle=wb.createFont();
        fonttitle.setItalic(true);
        fonttitle.setFontName("微软雅黑");
        fonttitle.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);//粗体
       
            CellStyle styletitle = wb.createCellStyle();
            styletitle.setFillForegroundColor(IndexedColors.BRIGHT_GREEN.getIndex());
            styletitle.setFillPattern(CellStyle.SOLID_FOREGROUND);
            styletitle.setFont(fonttitle);
            styletitle.setBorderLeft(CellStyle.BORDER_THIN);
            styletitle.setBorderRight(CellStyle.BORDER_THIN);
            styletitle.setBorderTop(CellStyle.BORDER_THIN);
            styletitle.setBorderBottom(CellStyle.BORDER_THIN);
           
      //正文样式
            //
            XSSFFont fontRed=wb.createFont();
            fontRed.setColor(HSSFColor.GREEN.index);
            fontRed.setColor(IndexedColors.RED.getIndex());
            fontRed.setFontName("微软雅黑");
            fontRed.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);//粗体
            fontRed.setFontHeightInPoints((short) 11);
        CellStyle styleRed = wb.createCellStyle();
        styleRed.setFont(fontRed);
        styleRed.setBorderLeft(CellStyle.BORDER_THIN);
        styleRed.setBorderRight(CellStyle.BORDER_THIN);
        styleRed.setBorderTop(CellStyle.BORDER_THIN);
        styleRed.setBorderBottom(CellStyle.BORDER_THIN);
           
            XSSFFont fontGreen=wb.createFont();
            fontGreen.setColor(IndexedColors.GREEN.getIndex());
            fontGreen.setFontName("微软雅黑");
            fontGreen.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);//粗体
            fontGreen.setFontHeightInPoints((short) 11);
        CellStyle styleGreen = wb.createCellStyle();
        styleGreen.setFont(fontGreen);
        styleGreen.setBorderLeft(CellStyle.BORDER_THIN);
        styleGreen.setBorderRight(CellStyle.BORDER_THIN);
        styleGreen.setBorderTop(CellStyle.BORDER_THIN);
        styleGreen.setBorderBottom(CellStyle.BORDER_THIN);
       
            XSSFFont fontBlack=wb.createFont();
            fontBlack.setColor(IndexedColors.BLACK.getIndex());
            fontBlack.setFontName("Arial");
            fontBlack.setFontHeightInPoints((short) 9);
        CellStyle styleBlack = wb.createCellStyle();
        styleBlack.setFont(fontBlack);
        styleBlack.setBorderLeft(CellStyle.BORDER_THIN);
        styleBlack.setBorderRight(CellStyle.BORDER_THIN);
        styleBlack.setBorderTop(CellStyle.BORDER_THIN);
View Full Code Here

  }

  private void handleCell(final XSSFWorkbook workbook, final XSSFRow row, final Cell cell, final int cellNum) {
    XSSFCell c = row.createCell(cellNum);

    XSSFFont font = workbook.createFont();
    font.setColor(this.getColor(cell.getFontColor()));
    font.setFontName(cell.getFont());
    font.setFontHeightInPoints((short) cell.getFontSize());

    if (cell.isBold()) {
      font.setBoldweight(Font.BOLDWEIGHT_BOLD);
    }

    if (cell.isItalic()) {
      font.setItalic(true);
    }

    if (cell.isStrikeout()) {
      font.setStrikeout(true);
    }

    if (cell.isUnderline()) {
      font.setUnderline(Font.U_SINGLE);
    }

    XSSFCellStyle style = workbook.createCellStyle();
    style.setAlignment(this.getAlignment(cell.getAlignment()));
    style.setVerticalAlignment(this.getVerticalAlignment(cell.getVerticalAlignment()));
View Full Code Here

TOP

Related Classes of org.apache.poi.xssf.usermodel.XSSFFont

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.