List of usage examples for org.apache.poi.ss.usermodel Font setFontName
void setFontName(String name);
From source file:uk.co.certait.htmlexporter.writer.excel.ExcelStyleGenerator.java
License:Apache License
public Font createFont(Workbook workbook, Style style) { Font font = workbook.createFont(); if (style.isFontNameSet()) { font.setFontName(style.getProperty(CssStringProperty.FONT_FAMILY)); }//www.java 2 s .com if (style.isFontSizeSet()) { font.setFontHeightInPoints((short) style.getProperty(CssIntegerProperty.FONT_SIZE)); } if (style.isColorSet()) { Color color = style.getProperty(CssColorProperty.COLOR); // if(! color.equals(Color.WHITE)) // POI Bug // { ((XSSFFont) font).setColor(new XSSFColor(color)); // } } if (style.isFontBold()) { font.setBoldweight(Font.BOLDWEIGHT_BOLD); } font.setItalic(style.isFontItalic()); if (style.isTextUnderlined()) { font.setUnderline(Font.U_SINGLE); } return font; }
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 w w . j a va 2s .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; }
From source file:utilities.XlsxGenerator.java
private CellStyle createStandardStyle() { CellStyle style = wb.createCellStyle(); style.setAlignment(CellStyle.ALIGN_CENTER); Font font = wb.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 8); style.setFont(font);//from w ww. j a v a 2 s . c o m // style.setBorderRight(CellStyle.BORDER_THIN); // style.setRightBorderColor(IndexedColors.BLACK.getIndex()); // style.setBorderBottom(CellStyle.BORDER_THIN); // style.setBottomBorderColor(IndexedColors.BLACK.getIndex()); // style.setBorderLeft(CellStyle.BORDER_THIN); // style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); // style.setBorderTop(CellStyle.BORDER_THIN); // style.setTopBorderColor(IndexedColors.BLACK.getIndex()); style.setWrapText(true); return style; }
From source file:utils.RecordsWriter.java
License:Open Source License
private HSSFCellStyle style() { HSSFCellStyle style = workbook.createCellStyle(); style.setAlignment(CellStyle.ALIGN_CENTER); Font font = workbook.createFont(); font.setFontHeightInPoints((short) 16); font.setFontName("Courier New"); font.setItalic(true);/*from w ww. j ava 2 s. c om*/ style.setFont(font); return style; }