List of usage examples for org.apache.poi.ss.usermodel FontUnderline SINGLE
FontUnderline SINGLE
To view the source code for org.apache.poi.ss.usermodel FontUnderline SINGLE.
Click Source Link
From source file:com.hauldata.dbpa.file.book.XlsxTargetSheet.java
License:Apache License
private static Font getFont(FontStyles fontStyles, SXSSFWorkbook book, Map<FontStyles, XSSFFont> fontsUsed, Map<Integer, XSSFColor> colorsUsed) { XSSFFont font = fontsUsed.get(fontStyles); if (font != null) { return font; }//w w w .j av a 2 s .c o m font = (XSSFFont) book.createFont(); if (fontStyles.color != null) { font.setColor(getColor(fontStyles.color, book, colorsUsed)); } if (fontStyles.fontStyle != null) { switch (fontStyles.fontStyle) { case NORMAL: break; case ITALIC: font.setItalic(true); break; } } if (fontStyles.fontWeight != null) { switch (fontStyles.fontWeight) { case NORMAL: break; case BOLD: font.setBold(true); break; } } if (fontStyles.textDecorationLine != null) { switch (fontStyles.textDecorationLine) { case NONE: break; case LINE_THROUGH: font.setStrikeout(true); break; case UNDERLINE: font.setUnderline((fontStyles.textDecorationStyle == FontStyles.TextDecorationStyle.DOUBLE) ? FontUnderline.DOUBLE : FontUnderline.SINGLE); break; } } fontsUsed.put(fontStyles, font); return font; }
From source file:net.mcnewfamily.rmcnew.model.excel.FontEssence.java
License:Open Source License
public XSSFFont toXSSFFont(XSSFWorkbook workbook) { XSSFFont xssfFont = null;/* ww w . j a va 2 s. c o m*/ if (workbook != null) { xssfFont = workbook.createFont(); xssfFont.setCharSet(FontCharset.DEFAULT); xssfFont.setFamily(this.fontFamily); xssfFont.setBold(this.bold); if (this.bold) { xssfFont.setBoldweight(Font.BOLDWEIGHT_BOLD); } else { xssfFont.setBoldweight(Font.BOLDWEIGHT_NORMAL); } xssfFont.setItalic(this.italic); if (this.underline) { xssfFont.setUnderline(FontUnderline.SINGLE); } xssfFont.setStrikeout(this.strikeout); xssfFont.setColor(this.color); xssfFont.setFontHeightInPoints(this.fontHeightInPoints); } else { throw new IllegalArgumentException("Cannot create XSSFFont in a null XSSFWorkbook!"); } return xssfFont; }
From source file:uk.co.spudsoft.birt.emitters.excel.FontManager.java
License:Open Source License
/** * Create a new POI Font based upon a BIRT style. * @param birtStyle/*from w ww . j av a2 s . c o m*/ * The BIRT style to base the Font upon. * @return * The Font whose attributes are described by the BIRT style. */ private Font createFont(BirtStyle birtStyle) { Font font = workbook.createFont(); // Family String fontName = smu .poiFontNameFromBirt(cleanupQuotes(birtStyle.getProperty(StyleConstants.STYLE_FONT_FAMILY))); if (fontName == null) { fontName = "Calibri"; } font.setFontName(fontName); // Size short fontSize = smu.fontSizeInPoints(cleanupQuotes(birtStyle.getProperty(StyleConstants.STYLE_FONT_SIZE))); if (fontSize > 0) { font.setFontHeightInPoints(fontSize); } // Weight short fontWeight = smu .poiFontWeightFromBirt(cleanupQuotes(birtStyle.getProperty(StyleConstants.STYLE_FONT_WEIGHT))); if (fontWeight > 0) { font.setBoldweight(fontWeight); } // Style String fontStyle = cleanupQuotes(birtStyle.getProperty(StyleConstants.STYLE_FONT_STYLE)); if (CSSConstants.CSS_ITALIC_VALUE.equals(fontStyle) || CSSConstants.CSS_OBLIQUE_VALUE.equals(fontStyle)) { font.setItalic(true); } // Underline String fontUnderline = cleanupQuotes(birtStyle.getProperty(StyleConstants.STYLE_TEXT_UNDERLINE)); if (CSSConstants.CSS_UNDERLINE_VALUE.equals(fontUnderline)) { font.setUnderline(FontUnderline.SINGLE.getByteValue()); } // Colour smu.addColourToFont(workbook, font, cleanupQuotes(birtStyle.getProperty(StyleConstants.STYLE_COLOR))); fonts.add(new FontPair(birtStyle, font)); return font; }