Package org.apache.poi.hssf.usermodel

Examples of org.apache.poi.hssf.usermodel.HSSFFont


     */
    @Override
    protected void writeCaption(TableModel model) throws Exception
    {
        HSSFCellStyle style = this.wb.createCellStyle();
        HSSFFont bold = this.wb.createFont();
        bold.setBoldweight(Font.BOLDWEIGHT_BOLD);
        bold.setFontHeightInPoints((short) 14);
        style.setFont(bold);
        style.setAlignment(CellStyle.ALIGN_CENTER);

        this.colNum = 0;
        this.currentRow = this.sheet.createRow(this.sheetRowNum++);
View Full Code Here


    private HSSFCellStyle getHeaderFooterStyle()
    {
        HSSFCellStyle style = this.wb.createCellStyle();
        // style.setFillPattern(HSSFCellStyle.FINE_DOTS);
        // style.setFillBackgroundColor(HSSFColor.BLUE_GREY.index);
        HSSFFont bold = this.wb.createFont();
        bold.setBoldweight(Font.BOLDWEIGHT_BOLD);
        // bold.setColor(HSSFColor.WHITE.index);
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBottomBorderColor(IndexedColors.BLACK.getIndex());

        style.setFont(bold);
View Full Code Here

      short[] rgb = color.getTriplet();
      css(td,"background-color",String.format("#%02x%02x%02x", rgb[0],rgb[1],rgb[2]));
    }
   
   
    HSSFFont font = style.getFont(book);
    if(font!=null){
      css(td,"font-family",font.getFontName());
      colorIndex = font.getColor();
      color = palette.getColor(colorIndex);
      if(color!=null){
//      if(colorIndex!=HSSF_AUTO.getIndex()&&color!=null){
        short[] rgb = color.getTriplet();
        css(td,"color",String.format("#%02x%02x%02x", rgb[0],rgb[1],rgb[2]));
      }
      css(td,"font-size",String.format("%dpx",pointsToPixels(font.getFontHeightInPoints())));
     
      // 20111024 对于
      // 1 styleLeft
      // 2 styleCenter
      // 3 styleRight
      // 和
      // 4 styleTop
      // 5 styleMiddle
      // 6 styleBottom 需要设置对应的td的valign和align属性
      // 7 styleBold
      // 8 styleItalics
      // 9 styleUnderline
      // 10 styleLineThrough
     
      if(HSSFFont.BOLDWEIGHT_BOLD==font.getBoldweight()){
        classes(td,"styleBold");
      }
      if(font.getItalic()){
        classes(td,"styleItalics")
      }
      switch(font.getUnderline()){
      case HSSFFont.U_DOUBLE:
      case HSSFFont.U_DOUBLE_ACCOUNTING:
      case HSSFFont.U_SINGLE:
      case HSSFFont.U_SINGLE_ACCOUNTING:
        classes(td,"styleUnderline");
      }
      if(font.getStrikeout()){
        classes(td,"styleLineThrough");
      }
    }

    switch(style.getAlignment()){
View Full Code Here

            }else{
                style = sheet.getWorkbook()
                    .createCellStyle();
                HSSFPalette palette = sheet.getWorkbook()
                    .getCustomPalette();
                HSSFFont font = sheet.getWorkbook().createFont();
                styleApplier(style, font, td, palette,styleContainer);
                cell.setCellStyle(style);
                styleContainer.cellStyleMap.put(styleKey, style);
            }
View Full Code Here

      style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
      style.setBorderRight(HSSFCellStyle.BORDER_THIN);
      style.setBorderTop(HSSFCellStyle.BORDER_THIN);
      style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
      // 生成一个字体
      HSSFFont font = workbook.createFont();
      font.setFontHeightInPoints((short) 12);
      font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
      // 把字体应用到当前的样式
      style.setFont(font);
     
      HSSFCellStyle styledata = workbook.createCellStyle();
      // 设置这些样式
View Full Code Here

      style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
      style.setBorderRight(HSSFCellStyle.BORDER_THIN);
      style.setBorderTop(HSSFCellStyle.BORDER_THIN);
      style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
      // 生成一个字体
      HSSFFont font = workbook.createFont();
      font.setFontHeightInPoints((short) 12);
      font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
      // 把字体应用到当前的样式
      style.setFont(font);

      HSSFCellStyle styledata = workbook.createCellStyle();
      // 设置这些样式
View Full Code Here

      style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
      style.setBorderRight(HSSFCellStyle.BORDER_THIN);
      style.setBorderTop(HSSFCellStyle.BORDER_THIN);
      style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
      // 生成一个字体
      HSSFFont font = workbook.createFont();
      font.setFontHeightInPoints((short) 12);
      font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
      // 把字体应用到当前的样式
      style.setFont(font);
     
      HSSFCellStyle styledata = workbook.createCellStyle();
      // 设置这些样式
View Full Code Here

            }
        }
    }

    private boolean isBlank(HSSFCellStyle style) {
        HSSFFont font = null;
        if (style.getFontIndex() > 0) {
            font = (_workbook.getWorkbook().getFontAt(style.getFontIndex()));
        }
        if (style.getBorderBottom() == 0 && style.getBorderTop() == 0
            && style.getBorderRight() == 0 && style.getBorderLeft() == 0
            && style.getFillBackgroundColor() == HSSFColor.WHITE.index
            && style.getFillPattern() == 0 && (style.getFontIndex() == 0
                || ((font.getFontName().equals("Arial")
                    || font.getFontName().equals("Helvetica"))
                    && font.getFontHeightInPoints() > 8
                    && font.getFontHeightInPoints() < 12))) {
            return true;
        }
        return false;
    }
View Full Code Here

            HSSFColor color = null;

            HSSFCellStyle style = pstyle.getStyle();
            //style.setFillForegroundColor(
            Workbook workbook = getWorkbook();
            HSSFFont font = workbook.createFont();
            style.setFont(font);
            font.setFontHeightInPoints((short)getUnit());
            //font.setFontName(getFont());
            font.setItalic(getItalic());
            if (getBold()) {
                font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            } else {
                font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
            }
            font.setUnderline((byte)getUnderline());
            font.setStrikeout(getStrikeThrough());

            color = (HSSFColor)colorhash.get(
                    pstyle.getForegroundColor().toString());
            //System.out.println(pstyle.getForegroundColor().toString());
            if (color == null)
                color = new HSSFColor.BLACK();
            font.setColor(color.getIndex());
            hssfFont = font;
        }
    }
View Full Code Here

    /**
     * create a font in the underlying HSSF model and return the reference
     */
    HSSFFont createFont() {
        HSSFFont font = _workbook.createFont();
        return font;
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.usermodel.HSSFFont

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.