Java Code Examples for org.apache.poi.ss.usermodel.Font#getFontHeightInPoints()
The following examples show how to use
org.apache.poi.ss.usermodel.Font#getFontHeightInPoints() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HSSFFontWrapper.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Creates a HSSFFontWrapper for the excel font. * * @param font * the font. */ public HSSFFontWrapper( final Font font ) { if ( font == null ) { throw new NullPointerException( "Font is null" ); } if ( font.getColor() < 0 ) { throw new IllegalArgumentException( "Negative color index is not allowed" ); } fontName = normalizeFontName( font.getFontName() ); fontHeight = font.getFontHeightInPoints(); bold = font.getBold(); italic = font.getItalic(); underline = ( font.getUnderline() != HSSFFont.U_NONE ); strikethrough = font.getStrikeout(); colorIndex = font.getColor(); }
Example 2
Source File: StylerHelper.java From autopoi with Apache License 2.0 | 5 votes |
private void fontStyle(Font font) { if (font.getBoldweight() >= Font.BOLDWEIGHT_BOLD) out.format(" font-weight: bold;%n"); if (font.getItalic()) out.format(" font-style: italic;%n"); out.format(" font-family: %s;%n", font.getFontName()); int fontheight = font.getFontHeightInPoints(); if (fontheight == 9) { fontheight = 10; } out.format(" font-size: %dpt;%n", fontheight); helper.styleColor(out, "color", getColor(font)); }
Example 3
Source File: StylerHelper.java From jeasypoi with Apache License 2.0 | 5 votes |
private void fontStyle(Font font) { if (font.getBoldweight() >= Font.BOLDWEIGHT_BOLD) out.format(" font-weight: bold;%n"); if (font.getItalic()) out.format(" font-style: italic;%n"); out.format(" font-family: %s;%n", font.getFontName()); int fontheight = font.getFontHeightInPoints(); if (fontheight == 9) { fontheight = 10; } out.format(" font-size: %dpt;%n", fontheight); helper.styleColor(out, "color", getColor(font)); }
Example 4
Source File: StylerHelper.java From easypoi with Apache License 2.0 | 5 votes |
private void fontStyle(Font font) { if (font.getBoldweight() >= Font.BOLDWEIGHT_BOLD) out.format(" font-weight: bold;%n"); if (font.getItalic()) out.format(" font-style: italic;%n"); out.format(" font-family: %s;%n", font.getFontName()); int fontheight = font.getFontHeightInPoints(); if (fontheight == 9) { fontheight = 10; } out.format(" font-size: %dpt;%n", fontheight); helper.styleColor(out, "color", getColor(font)); }
Example 5
Source File: AbstractSheet.java From tools with Apache License 2.0 | 5 votes |
/** * @param cell * @return */ @SuppressWarnings("deprecation") private int getNumWrappedLines(Cell cell) { if (cell.getCellTypeEnum() == CellType.STRING) { String val = cell.getStringCellValue(); if (val == null || val.isEmpty()) { return 1; } CellStyle style = cell.getCellStyle(); if (style == null || !style.getWrapText()) { return 1; } Font font = sheet.getWorkbook().getFontAt(style.getFontIndex()); AttributedString astr = new AttributedString(val); java.awt.Font awtFont = new java.awt.Font(font.getFontName(), 0, font.getFontHeightInPoints()); float cellWidth = sheet.getColumnWidth(cell.getColumnIndex())/ 256F * 5.5F; astr.addAttribute(TextAttribute.FONT, awtFont); FontRenderContext context = new FontRenderContext(null, true, true); java.awt.font.LineBreakMeasurer measurer = new java.awt.font.LineBreakMeasurer(astr.getIterator(), context); int pos = 0; int numLines = 0; while (measurer.getPosition() < val.length()) { pos = measurer.nextOffset(cellWidth); numLines++; measurer.setPosition(pos); } return numLines; } else { // Not a string type return 1; } }