Example usage for org.apache.poi.ss.usermodel Font getUnderline

List of usage examples for org.apache.poi.ss.usermodel Font getUnderline

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Font getUnderline.

Prototype


byte getUnderline();

Source Link

Document

get type of text underlining to use

Usage

From source file:org.netxilia.impexp.impl.PoiUtils.java

License:Open Source License

public static Styles poiStyle2Netxilia(CellStyle poiStyle, Font font, HSSFPalette palette,
        NetxiliaStyleResolver styleResolver) {
    List<Style> entries = new ArrayList<Style>();

    if (!poiStyle.getWrapText()) {
        entries.add(DefaultStyle.nowrap.getStyle());
    }//w w  w . ja  v  a  2 s  . co  m
    // font
    if (font.getItalic()) {
        entries.add(DefaultStyle.italic.getStyle());
    }
    if (font.getStrikeout()) {
        entries.add(DefaultStyle.strikeout.getStyle());
    }
    if (font.getBoldweight() == Font.BOLDWEIGHT_BOLD) {
        entries.add(DefaultStyle.bold.getStyle());
    }
    if (font.getUnderline() != Font.U_NONE) {
        entries.add(DefaultStyle.underline.getStyle());
    }
    // borders
    if (poiStyle.getBorderBottom() != CellStyle.BORDER_NONE) {
        entries.add(DefaultStyle.borderBottom.getStyle());
    }
    if (poiStyle.getBorderLeft() != CellStyle.BORDER_NONE) {
        entries.add(DefaultStyle.borderLeft.getStyle());
    }
    if (poiStyle.getBorderTop() != CellStyle.BORDER_NONE) {
        entries.add(DefaultStyle.borderTop.getStyle());
    }
    if (poiStyle.getBorderRight() != CellStyle.BORDER_NONE) {
        entries.add(DefaultStyle.borderRight.getStyle());
    }
    // align
    switch (poiStyle.getAlignment()) {
    case CellStyle.ALIGN_LEFT:
        entries.add(DefaultStyle.alignLeft.getStyle());
        break;
    case CellStyle.ALIGN_RIGHT:
        entries.add(DefaultStyle.alignRight.getStyle());
        break;
    case CellStyle.ALIGN_CENTER:
        entries.add(DefaultStyle.alignCenter.getStyle());
        break;
    case CellStyle.ALIGN_JUSTIFY:
        entries.add(DefaultStyle.alignJustify.getStyle());
        break;
    }
    if (font != null && font.getColor() != 0) {
        HSSFColor poiForeground = palette.getColor(font.getColor());
        if (poiForeground != null && poiForeground != HSSFColor.AUTOMATIC.getInstance()) {
            Style foregroundDef = styleResolver.approximateForeground(poiForeground.getTriplet()[0],
                    poiForeground.getTriplet()[1], poiForeground.getTriplet()[2]);
            if (foregroundDef != null) {
                entries.add(foregroundDef);
            }
        }
    }

    if (poiStyle.getFillForegroundColor() != 0) {
        HSSFColor poiBackground = palette.getColor(poiStyle.getFillForegroundColor());
        if (poiBackground != null && poiBackground != HSSFColor.AUTOMATIC.getInstance()) {
            Style backgroundDef = styleResolver.approximateBackground(poiBackground.getTriplet()[0],
                    poiBackground.getTriplet()[1], poiBackground.getTriplet()[2]);
            if (backgroundDef != null) {
                entries.add(backgroundDef);
            }
        }
    }
    return entries.size() > 0 ? Styles.styles(entries) : null;
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.xls.helper.HSSFFontWrapper.java

License:Open Source License

/**
 * Creates a HSSFFontWrapper for the excel font.
 *
 * @param font/*from w  ww.  j  ava  2  s.c o  m*/
 *          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();
}

From source file:org.tiefaces.components.websheet.utility.CellStyleUtility.java

License:MIT License

/**
 * Get font decoration./*from  w w w  .  ja  v  a2s.co m*/
 * 
 * @param font
 *            font.
 * @return font decoration.
 */
private static String getCellFontDecoration(final Font font) {
    StringBuilder decoration = new StringBuilder();
    if (font.getUnderline() != 0) {
        decoration.append(" underline");
    }
    if (font.getStrikeout()) {
        decoration.append(" line-through");
    }
    return decoration.toString();
}

From source file:ru.icc.cells.ssdc.DataLoader.java

License:Apache License

private void fillFont(CFont font, Font excelFont) {
    font.setName(excelFont.getFontName());

    // TODO    CFont font
    //font.setColor( excelFont.getColor() );

    font.setHeight(excelFont.getFontHeight());
    font.setHeightInPoints(excelFont.getFontHeightInPoints());

    // TODO ?  ? Boldweight, ?? ? ? 
    short boldWeight = excelFont.getBoldweight();
    if (boldWeight >= 700)
        font.setBold(true);//from ww w .  j  av a2s . c om

    font.setItalic(excelFont.getItalic());
    font.setStrikeout(excelFont.getStrikeout());

    byte underline = excelFont.getUnderline();
    if (underline != Font.U_NONE)
        font.setUnderline(true);
    if (underline == Font.U_DOUBLE || underline == Font.U_DOUBLE_ACCOUNTING)
        font.setDoubleUnderline(true);
}

From source file:uk.co.spudsoft.birt.emitters.excel.StyleManagerUtils.java

License:Open Source License

/**
 * Add font details to an AttributedString.
 * @param attrString/*from w w w  . ja v a 2  s  .co m*/
 * The AttributedString to modify.
 * @param font
 * The font to take attributes from.
 * @param startIdx
 * The index of the first character to be attributed (inclusive).
 * @param endIdx
 * The index of the last character to be attributed (inclusive). 
 */
protected void addFontAttributes(AttributedString attrString, Font font, int startIdx, int endIdx) {
    attrString.addAttribute(TextAttribute.FAMILY, font.getFontName(), startIdx, endIdx);
    attrString.addAttribute(TextAttribute.SIZE, (float) font.getFontHeightInPoints(), startIdx, endIdx);
    if (font.getBoldweight() == Font.BOLDWEIGHT_BOLD)
        attrString.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, startIdx, endIdx);
    if (font.getItalic())
        attrString.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, startIdx, endIdx);
    if (font.getUnderline() == Font.U_SINGLE)
        attrString.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, startIdx, endIdx);
}