Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.Font


    // Funny one: Please note that the layout will be broken if the first
    // font is not 'Arial 10'.
    final short numberOfFonts = this.workbook.getNumberOfFonts();
    for (int i = 0; i < numberOfFonts; i++)
    {
      final Font font = workbook.getFontAt((short) i);
      this.fonts.put(new HSSFFontWrapper(font), font);
    }

    // add the default font
    // this MUST be the first one, that is created.
View Full Code Here


    {
      return (Font) fonts.get(wrapper);
    }

    // ok, we need a new one ...
    final Font excelFont = createFont(wrapper);
    fonts.put(wrapper, excelFont);
    return excelFont;
  }
View Full Code Here

   * @param wrapper the font wrapper that holds all font information from the repagination.
   * @return the created font.
   */
  private Font createFont(final HSSFFontWrapper wrapper)
  {
    final Font font = workbook.createFont();
    if (wrapper.isBold())
    {
      font.setBoldweight(Font.BOLDWEIGHT_BOLD);
    }
    else
    {
      font.setBoldweight(Font.BOLDWEIGHT_NORMAL);
    }
    font.setColor(wrapper.getColorIndex());
    font.setFontName(wrapper.getFontName());
    font.setFontHeightInPoints((short) wrapper.getFontHeight());
    font.setItalic(wrapper.isItalic());
    font.setStrikeout(wrapper.isStrikethrough());
    if (wrapper.isUnderline())
    {
      font.setUnderline(Font.U_SINGLE);
    }
    else
    {
      font.setUnderline(Font.U_NONE);
    }
    return font;
  }
View Full Code Here

        final boolean italic = styleSheet.getBooleanStyleProperty(TextStyleKeys.ITALIC);
        final boolean underline = styleSheet.getBooleanStyleProperty(TextStyleKeys.UNDERLINED);
        final boolean strikethrough = styleSheet.getBooleanStyleProperty(TextStyleKeys.STRIKETHROUGH);
        final HSSFFontWrapper wrapper = new HSSFFontWrapper
            (fontName, fontSize, bold, italic, underline, strikethrough, fontColorProducer.getNearestColor(textColor));
        final Font excelFont = fontFactory.getExcelFont(wrapper);
        this.font = excelFont.getIndex();

        final ElementAlignment horizontal =
            (ElementAlignment) styleSheet.getStyleProperty(ElementStyleKeys.ALIGNMENT);
        this.horizontalAlignment = HSSFCellStyleProducer.convertAlignment(horizontal);
        final ElementAlignment vertical =
View Full Code Here

          int startingFonts = initialFonts[i];
         
          assertEquals(startingFonts, wb.getNumberOfFonts());
         
          // Get a font, and slightly change it
          Font a = wb.createFont();
          assertEquals(startingFonts+1, wb.getNumberOfFonts());
          a.setFontHeightInPoints((short)23);
          assertEquals(startingFonts+1, wb.getNumberOfFonts());
         
          // Get two more, unchanged
          Font b = wb.createFont();
          assertEquals(startingFonts+2, wb.getNumberOfFonts());
          Font c = wb.createFont();
          assertEquals(startingFonts+3, wb.getNumberOfFonts());
       }
    }
View Full Code Here

          "This line finishes with two trailing spaces.  ";
      
       XSSFWorkbook wb = new XSSFWorkbook();
       XSSFSheet sheet = wb.createSheet();

       Font font1 = wb.createFont();
       font1.setColor((short) 20);
       Font font2 = wb.createFont();
       font2.setColor(Font.COLOR_RED);
       Font font3 = wb.getFontAt((short)0);

       XSSFRow row = sheet.createRow(2);
       XSSFCell cell = row.createCell(2);

       XSSFRichTextString richTextString =
View Full Code Here

            throw new IllegalArgumentException("workbook must not be null"); //$NON-NLS-1$
        }
        this.workbook = workbook;
        this.version = WorkbookGenerator.getSpreadsheetVersion(workbook);

        Font font = workbook.createFont();
        // font.setFontName("MS ゴシック");

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

        if (workbook == null) {
            throw new IllegalArgumentException("workbook must not be null"); //$NON-NLS-1$
        }
        this.workbook = workbook;

        Font font = workbook.createFont();
        // font.setFontName("MS ゴシック");

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

            return Style.NO_STYLE;
        }
        final CellStyle cellStyle = cell.getCellStyle();

        final short fontIndex = cellStyle.getFontIndex();
        final Font font = workbook.getFontAt(fontIndex);
        final StyleBuilder styleBuilder = new StyleBuilder();

        // Font bold, italic, underline
        if (font.getBoldweight() >= Font.BOLDWEIGHT_BOLD) {
            styleBuilder.bold();
        }
        if (font.getItalic()) {
            styleBuilder.italic();
        }
        if (font.getUnderline() != FontUnderline.NONE.getByteValue()) {
            styleBuilder.underline();
        }

        // Font size
        final Font stdFont = workbook.getFontAt((short) 0);
        final short fontSize = font.getFontHeightInPoints();
        if (stdFont.getFontHeightInPoints() != fontSize) {
            styleBuilder.fontSize(fontSize, SizeUnit.PT);
        }

        // Font color
        final short colorIndex = font.getColor();
View Full Code Here

    // Funny one: Please note that the layout will be broken if the first
    // font is not 'Arial 10'.
    final short numberOfFonts = this.workbook.getNumberOfFonts();
    for (int i = 0; i < numberOfFonts; i++)
    {
      final Font font = workbook.getFontAt((short) i);
      this.fonts.put(new HSSFFontWrapper(font), font);
    }

    // add the default font
    // this MUST be the first one, that is created.
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.usermodel.Font

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.