Package org.apache.poi.xssf.usermodel

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


            CTFonts ctfonts = styleSheet.getFonts();
            if(ctfonts != null){
        int idx = 0;
        for (CTFont font : ctfonts.getFontArray()) {
           // Create the font and save it. Themes Table supplied later
          XSSFFont f = new XSSFFont(font, idx);
          fonts.add(f);
          idx++;
        }
      }
            CTFills ctfills = styleSheet.getFills();
View Full Code Here


    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

            "800080"  // FolHlink
        };
        boolean createFile = false;
        int i=0;
        for (Row row : workbook.getSheetAt(0)) {
            XSSFFont font = ((XSSFRow)row).getCell(0).getCellStyle().getFont();
            XSSFColor color = font.getXSSFColor();
            assertEquals("Failed color theme "+i, rgbExpected[i], Hex.encodeHexString(color.getRgb()));
            long themeIdx = font.getCTFont().getColorArray(0).getTheme();
            assertEquals("Failed color theme "+i, i, themeIdx);
            if (createFile) {
                XSSFCellStyle cs = (XSSFCellStyle)row.getSheet().getWorkbook().createCellStyle();
                cs.setFillForegroundColor(color);
                cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
View Full Code Here

        numberFormats.put(newKey, fmt);
        return newKey;
    }
   
    public Font getFontAt(long idx) {
      return new XSSFFont(fonts.get((int) idx));
    }
View Full Code Here

    private long putFont(XSSFFont font, ArrayList<CTFont> fonts) {
      return font.putFont(fonts);
  }
  private void initialize() {
    //CTFont ctFont = createDefaultFont();
    XSSFFont xssfFont = createDefaultFont();
      fonts.add(xssfFont.getCTFont());
     
      CTFill ctFill = createDefaultFill();
      fills.add(ctFill);
     
      CTBorder ctBorder = createDefaultBorder();
View Full Code Here

      ctFont.addNewScheme().setVal(STFontScheme.MINOR);
      XSSFFont font=new XSSFFont(ctFont);
    return font;
    */
    CTFont ctFont = CTFont.Factory.newInstance();   
    XSSFFont xssfFont=new XSSFFont(ctFont);
    xssfFont.setFontHeightInPoints(XSSFFont.DEFAULT_FONT_SIZE);
    xssfFont.setColor(XSSFFont.DEFAULT_FONT_COLOR);//setTheme
    xssfFont.setFontName(XSSFFont.DEFAULT_FONT_NAME);
    xssfFont.setFamily(XSSFFont.FONT_FAMILY_SWISS);
    xssfFont.setScheme(XSSFFont.SCHEME_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

        numberFormats.put((int)nfmt.getNumFmtId(), nfmt.getFormatCode());
      }
      if(doc.getStyleSheet().getFonts() != null){
                int idx = 0;
                for (CTFont font : doc.getStyleSheet().getFonts().getFontArray()) {
                    XSSFFont f = new XSSFFont(font, idx);
                    fonts.add(f);
                    idx++;
                }
            }
      if(doc.getStyleSheet().getFills() != null)
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.