/** * Finds a font that matches the one with the supplied attributes */ @Override public HSSFFont findFont(boolean bold, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) { int numberOfFonts = getNumberOfFontsAsInt(); for (int i = 0; i <= numberOfFonts; i++) { // Remember - there is no 4! if(i == 4) { continue; } HSSFFont hssfFont = getFontAt(i); if (hssfFont.getBold() == bold && hssfFont.getColor() == color && hssfFont.getFontHeight() == fontHeight && hssfFont.getFontName().equals(name) && hssfFont.getItalic() == italic && hssfFont.getStrikeout() == strikeout && hssfFont.getTypeOffset() == typeOffset && hssfFont.getUnderline() == underline) { return hssfFont; } } return null; }
private FontMetrics getFontMetrics(HSSFFont hf){ FontMetrics fm; Short pFont = hf.getIndex(); fm = fontMetrics.get(pFont); if (fm == null) { int style; if (hf.getBold() || hf.getItalic()) { style = 0; if (hf.getBold()) style ^= Font.BOLD; if (hf.getItalic()) style ^= Font.ITALIC; } else { style = Font.PLAIN; } Font f = new java.awt.Font(hf.getFontName(), style, hf.getFontHeightInPoints()); if (graphics == null) { BufferedImage i = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_GRAY); graphics = i.createGraphics(); } fm = graphics.getFontMetrics(f); fontMetrics.put(pFont, fm); } return fm; }
void buildStyle_font( HSSFWorkbook workbook, StringBuilder style, HSSFFont font ) { if ( font.getBold() ) { style.append( "font-weight:bold;" ); } final HSSFColor fontColor = workbook.getCustomPalette().getColor( font.getColor() ); if ( fontColor != null ) style.append("color: ").append(ExcelToHtmlUtils.getColor(fontColor)).append("; "); if ( font.getFontHeightInPoints() != 0 ) style.append("font-size:").append(font.getFontHeightInPoints()).append("pt;"); if ( font.getItalic() ) { style.append( "font-style:italic;" ); } }
/** * Creates a new font for a specific cell style */ public static Font makeFont(HSSFFont font) { boolean isbold = font.getBoldweight() > HSSFFont.BOLDWEIGHT_NORMAL; boolean isitalics = font.getItalic(); int fontstyle = Font.PLAIN; if (isbold) { fontstyle = Font.BOLD; } if (isitalics) { fontstyle = fontstyle | Font.ITALIC; } int fontheight = font.getFontHeightInPoints(); if (fontheight == 9) { //fix for stupid ol Windows fontheight = 10; } return new Font(font.getFontName(), fontstyle, fontheight); }
/** * Creates a new font for a specific cell style */ public static Font makeFont(HSSFFont font) { boolean isbold = font.getBold(); boolean isitalics = font.getItalic(); int fontstyle = Font.PLAIN; if (isbold) { fontstyle = Font.BOLD; } if (isitalics) { fontstyle = fontstyle | Font.ITALIC; } int fontheight = font.getFontHeightInPoints(); if (fontheight == 9) { //fix for stupid ol Windows fontheight = 10; } return new Font(font.getFontName(), fontstyle, fontheight); }
/** * Creates a new font for a specific cell style */ public static Font makeFont(HSSFFont font) { boolean isbold = font.getBoldweight() > HSSFFont.BOLDWEIGHT_NORMAL; boolean isitalics = font.getItalic(); int fontstyle = Font.PLAIN; if (isbold) { fontstyle = Font.BOLD; } if (isitalics) { fontstyle = fontstyle | Font.ITALIC; } int fontheight = font.getFontHeightInPoints(); if (fontheight == 9) { //fix for stupid ol Windows fontheight = 10; } return new Font(font.getFontName(), fontstyle, fontheight); }
void buildStyle_font( HSSFWorkbook workbook, StringBuilder style, HSSFFont font ) { switch ( font.getBoldweight() ) { case HSSFFont.BOLDWEIGHT_BOLD: style.append( "font-weight:bold;" ); break; case HSSFFont.BOLDWEIGHT_NORMAL: // by default, not not increase HTML size // style.append( "font-weight: normal; " ); break; } final HSSFColor fontColor = workbook.getCustomPalette().getColor( font.getColor() ); if ( fontColor != null ) style.append( "color: " + ExcelToHtmlUtils.getColor( fontColor ) + "; " ); if ( font.getFontHeightInPoints() != 0 ) style.append( "font-size:" + font.getFontHeightInPoints() + "pt;" ); if ( font.getItalic() ) { style.append( "font-style:italic;" ); } }
protected void processCellStyleFont( HSSFWorkbook workbook, Element blockTarget, HSSFFont font ) { Triplet triplet = new Triplet(); triplet.fontName = font.getFontName(); triplet.bold = font.getBold(); triplet.italic = font.getItalic(); getFontReplacer().update( triplet ); setBlockProperties( blockTarget, triplet ); final HSSFColor fontColor = workbook.getCustomPalette().getColor( font.getColor() ); if ( fontColor != null ) blockTarget.setAttribute( "color", ExcelToHtmlUtils.getColor( fontColor ) ); if ( font.getFontHeightInPoints() != 0 ) blockTarget.setAttribute( "font-size", font.getFontHeightInPoints() + "pt" ); }
/** * Finds a font that matches the one with the supplied attributes */ public HSSFFont findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) { for (short i=0; i<=getNumberOfFonts(); i++) { // Remember - there is no 4! if(i == 4) continue; HSSFFont hssfFont = getFontAt(i); if (hssfFont.getBoldweight() == boldWeight && hssfFont.getColor() == color && hssfFont.getFontHeight() == fontHeight && hssfFont.getFontName().equals(name) && hssfFont.getItalic() == italic && hssfFont.getStrikeout() == strikeout && hssfFont.getTypeOffset() == typeOffset && hssfFont.getUnderline() == underline) { return hssfFont; } } return null; }
/** * Finds a font that matches the one with the supplied attributes */ public HSSFFont findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) { for (short i=0; i<=getNumberOfFonts(); i++) { // Remember - there is no 4! if(i == 4) continue; HSSFFont hssfFont = getFontAt(i); if (hssfFont.getBoldweight() == boldWeight && hssfFont.getColor() == color && hssfFont.getFontHeight() == fontHeight && hssfFont.getFontName().equals(name) && hssfFont.getItalic() == italic && hssfFont.getStrikeout() == strikeout && hssfFont.getTypeOffset() == typeOffset && hssfFont.getUnderline() == underline) { return hssfFont; } } return null; }
/** * Finds a font that matches the one with the supplied attributes */ @Override public HSSFFont findFont(boolean bold, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) { int numberOfFonts = getNumberOfFontsAsInt(); for (int i = 0; i <= numberOfFonts; i++) { // Remember - there is no 4! if(i == 4) { continue; } HSSFFont hssfFont = getFontAt(i); if (hssfFont.getBold() == bold && hssfFont.getColor() == color && hssfFont.getFontHeight() == fontHeight && hssfFont.getFontName().equals(name) && hssfFont.getItalic() == italic && hssfFont.getStrikeout() == strikeout && hssfFont.getTypeOffset() == typeOffset && hssfFont.getUnderline() == underline) { return hssfFont; } } return null; }
protected void processCellStyleFont( HSSFWorkbook workbook, Element blockTarget, HSSFFont font ) { Triplet triplet = new Triplet(); triplet.fontName = font.getFontName(); switch ( font.getBoldweight() ) { case HSSFFont.BOLDWEIGHT_BOLD: triplet.bold = true; break; case HSSFFont.BOLDWEIGHT_NORMAL: triplet.bold = false; break; } if ( font.getItalic() ) { triplet.italic = true; } getFontReplacer().update( triplet ); setBlockProperties( blockTarget, triplet ); final HSSFColor fontColor = workbook.getCustomPalette().getColor( font.getColor() ); if ( fontColor != null ) blockTarget.setAttribute( "color", ExcelToHtmlUtils.getColor( fontColor ) ); if ( font.getFontHeightInPoints() != 0 ) blockTarget.setAttribute( "font-size", font.getFontHeightInPoints() + "pt" ); }
HSSFFont f = wb.getFontAt(style.getFontIndex()); boolean isbold = f.getBoldweight() > HSSFFont.BOLDWEIGHT_NORMAL; boolean isitalics = f.getItalic();
HSSFFont f = wb.getFontAt(style.getFontIndex()); boolean isbold = f.getBoldweight() > HSSFFont.BOLDWEIGHT_NORMAL; boolean isitalics = f.getItalic();
(cf.getStrikeout() == font.isStrikeThrough()) && ((cf.getBoldweight() == HSSFFont.BOLDWEIGHT_BOLD)?(font.isBold()):(!font.isBold())) && (cf.getItalic() == font.isItalic()) && (cf.getTypeOffset() == superscriptType)
HSSFFont f = wb.getFontAt(style.getFontIndexAsInt()); boolean isbold = f.getBold(); boolean isitalics = f.getItalic();
newFont.setItalic(cellFont.getItalic()); newFont.setStrikeout(cellFont.getStrikeout()); newFont.setTypeOffset(cellFont.getTypeOffset());
newFont.setItalic(cellFont.getItalic()); newFont.setStrikeout(cellFont.getStrikeout()); newFont.setTypeOffset(cellFont.getTypeOffset());
style.setBold(true); if(font.getItalic()){ style.setItalic(true);