Examples of HSSFFont


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

      Map attributes = iterator.getAttributes();
      JRFont runFont = attributes.isEmpty()? defaultFont : new JRBaseFont(attributes);
      short runForecolor = attributes.get(TextAttribute.FOREGROUND) != null ?
          getWorkbookColor((Color)attributes.get(TextAttribute.FOREGROUND)).getIndex() :
          forecolor;
      HSSFFont font = getLoadedFont(runFont, runForecolor, attributes, locale);
      richTextStr.applyFont(iterator.getIndex(), runLimit, font);
      iterator.setIndex(runLimit);
    }
    return richTextStr;
  }
View Full Code Here

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

  /**
   *
   */
  protected HSSFFont getLoadedFont(JRFont font, short forecolor, Map attributes, Locale locale)
  {
    HSSFFont cellFont = null;

    String fontName = font.getFontName();
    if (fontMap != null && fontMap.containsKey(fontName))
    {
      fontName = (String) fontMap.get(fontName);
    }
    else
    {
      FontInfo fontInfo = JRFontUtil.getFontInfo(fontName, locale);
      if (fontInfo != null)
      {
        //fontName found in font extensions
        FontFamily family = fontInfo.getFontFamily();
        String exportFont = family.getExportFont(getExporterKey());
        if (exportFont != null)
        {
          fontName = exportFont;
        }
      }
    }
   
    short superscriptType = HSSFFont.SS_NONE;
   
    if( attributes != null && attributes.get(TextAttribute.SUPERSCRIPT) != null)
    {
      Object value = attributes.get(TextAttribute.SUPERSCRIPT);
      if(TextAttribute.SUPERSCRIPT_SUPER.equals(value))
      {
        superscriptType = HSSFFont.SS_SUPER;
      }
      else if(TextAttribute.SUPERSCRIPT_SUB.equals(value))
      {
        superscriptType = HSSFFont.SS_SUB;
      }
     
    }
    for (int i = 0; i < loadedFonts.size(); i++)
    {
      HSSFFont cf = (HSSFFont)loadedFonts.get(i);

      short fontSize = (short)font.getFontSize();
      if (isFontSizeFixEnabled)
      {
        fontSize -= 1;
      }
      if (
        cf.getFontName().equals(fontName) &&
        (cf.getColor() == forecolor) &&
        (cf.getFontHeightInPoints() == fontSize) &&
        ((cf.getUnderline() == HSSFFont.U_SINGLE)?(font.isUnderline()):(!font.isUnderline())) &&
        (cf.getStrikeout() == font.isStrikeThrough()) &&
        ((cf.getBoldweight() == HSSFFont.BOLDWEIGHT_BOLD)?(font.isBold()):(!font.isBold())) &&
        (cf.getItalic() == font.isItalic()) &&
        (cf.getTypeOffset() == superscriptType)
        )
      {
        cellFont = cf;
        break;
      }
View Full Code Here

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

        }
    }

    private void configureColumnStyle() {
        assert workbook != null;
        HSSFFont font = workbook.createFont();
        font.setFontName("MS ゴシック");

        commonStyle = workbook.createCellStyle();
        commonStyle.setFont(font);
        commonStyle.setBorderTop(CellStyle.BORDER_THIN);
        commonStyle.setBorderBottom(CellStyle.BORDER_THIN);
View Full Code Here

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

                HSSFCell cell = headerRow.createCell(columnIndex);
                cell.setCellValue(columnName);

                HSSFCellStyle cellStyle = workbook.createCellStyle();
                HSSFFont tableHeadingFont = workbook.createFont();
                tableHeadingFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
                cellStyle.setFont(tableHeadingFont);
                cell.setCellStyle(cellStyle);
            }
        }
View Full Code Here

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

    return style;
  }

  public HSSFCellStyle createStyle(final short headFontSize,
      final short boldStyle, final short backgroundColor, short alignment) {
    HSSFFont font = wb.createFont();
    font.setFontHeightInPoints(headFontSize);
    font.setBoldweight(boldStyle);

    HSSFCellStyle cellStyle = wb.createCellStyle();
    cellStyle.setFont(font);
    cellStyle.setAlignment(alignment);
    cellStyle.setFillBackgroundColor(backgroundColor);
View Full Code Here

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

  }

  public HSSFCellStyle getStyle(short fontSize, short boldStyle,
      short alignment, short backgroundColor, Short borderLeft,
      Short borderTop, Short borderRight, Short borderBottom,String dataFormat) {
    HSSFFont font = fontMap.get(String.valueOf(fontSize)
        + String.valueOf(boldStyle));
    if(font==null){
    font = wb.createFont();
    font.setFontHeightInPoints(fontSize);
    font.setBoldweight(boldStyle);
    fontMap.put(String.valueOf(fontSize)
        + String.valueOf(boldStyle),font);
    }

    HSSFCellStyle cellStyle = wb.createCellStyle();
View Full Code Here

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

    }


    private boolean isBlank(HSSFCellStyle style) {

        HSSFFont font = null;
        if (style.getFontIndex() >0)
            font = ((HSSFFont)_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

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

            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

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

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

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

    // -------------------------------------------------------- Private Methods

    private HSSFWorkbook createWorkbook() {
        HSSFWorkbook wb = new HSSFWorkbook();

        HSSFFont font = wb.createFont();
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        HSSFSheet worksheet = wb.createSheet("Customers");
        worksheet.setColumnWidth((short) 0, (short)(20 * 256));
        worksheet.setColumnWidth((short) 1, (short)(30 * 256));
        worksheet.setColumnWidth((short) 4, (short)(20 * 256));

        HSSFRow row = worksheet.createRow((short)0);

        HSSFRichTextString value = new HSSFRichTextString("Customers");
        value.applyFont(font);
        row.createCell((short)0).setCellValue(value);

        row = worksheet.createRow((short)1);
        row.createCell((short)0).setCellValue(new HSSFRichTextString("Customer Account Details"));

        worksheet.createRow((short)2);

        row = worksheet.createRow((short)3);

        HSSFCellStyle style = wb.createCellStyle();
        style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        font = wb.createFont();
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        value = new HSSFRichTextString("Name");
        value.applyFont(font);
        HSSFCell cell = row.createCell((short)0);
        cell.setCellValue(value);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.