Example usage for org.apache.poi.xssf.usermodel XSSFFont getItalic

List of usage examples for org.apache.poi.xssf.usermodel XSSFFont getItalic

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFFont getItalic.

Prototype

public boolean getItalic() 

Source Link

Document

get a boolean value that specify whether to use italics or not

Usage

From source file:de.escnet.ExcelTable.java

License:Open Source License

private String styleFont(Map<String, String> styles, XSSFCell cell) {
    XSSFCellStyle cellStyle = cell.getCellStyle();
    if (cellStyle != null) {
        short fontIndex = cellStyle.getFontIndex();
        XSSFFont font = sheet.getWorkbook().getFontAt(fontIndex);

        if (font.getItalic()) {
            styles.put("font-style", "italic");
        }//  w  w  w .  j a va2 s  .c  o  m

        if (font.getBoldweight() == Font.BOLDWEIGHT_BOLD) {
            styles.put("font-weight", "bold");
        }

        styles.put("font", "" + font.getFontHeightInPoints() + "px " + font.getFontName());

        if (FONT_COLORS) {
            String color = getHtmlColor(font.getXSSFColor());
            if (color != null && !color.equals("#000000")) {
                return color;
            }
        }
    }

    return null;
}

From source file:org.apache.metamodel.excel.XlsxSheetToRowsHandler.java

License:Apache License

private void configureStyle(XSSFCellStyle style) {
    XSSFFont font = style.getFont();
    if (font.getBold()) {
        _style.bold();//from w ww .j ava  2 s  .  c o  m
    }
    if (font.getItalic()) {
        _style.italic();
    }
    if (font.getUnderline() != FontUnderline.NONE.getByteValue()) {
        _style.underline();
    }

    if (style.getFillPatternEnum() == FillPatternType.SOLID_FOREGROUND) {
        XSSFColor fillForegroundXSSFColor = style.getFillForegroundXSSFColor();
        String argb = fillForegroundXSSFColor.getARGBHex();
        if (argb != null) {
            _style.background(argb.substring(2));
        }
    }

    final XSSFFont stdFont = _stylesTable.getStyleAt(0).getFont();
    final short fontHeight = style.getFont().getFontHeightInPoints();
    if (stdFont.getFontHeightInPoints() != fontHeight) {
        _style.fontSize(fontHeight, SizeUnit.PT);
    }

    XSSFColor fontColor = style.getFont().getXSSFColor();
    if (fontColor != null) {
        String argbHex = fontColor.getARGBHex();
        if (argbHex != null) {
            _style.foreground(argbHex.substring(2));
        }
    }

    switch (style.getAlignmentEnum()) {
    case LEFT:
        _style.leftAligned();
        break;
    case RIGHT:
        _style.rightAligned();
        break;
    case CENTER:
        _style.centerAligned();
        break;
    case JUSTIFY:
        _style.justifyAligned();
        break;
    default:
        // do nothing
        break;
    }

}

From source file:org.sysmodb.xml.XSSFXMLStyleHelper.java

License:BSD License

public boolean areFontsEmpty(CellStyle style) {
    XSSFCellStyle newStyle = (XSSFCellStyle) style;
    XSSFFont font = newStyle.getFont();
    if (font.getBold())
        return false;
    if (font.getItalic())
        return false;
    if (font.getUnderline() != XSSFFont.U_NONE)
        return false;
    if (font.getFontHeight() != XSSFFont.DEFAULT_FONT_SIZE)
        return false;
    if (!font.getFontName().equals(XSSFFont.DEFAULT_FONT_NAME))
        return false;
    if (font.getColor() != XSSFFont.DEFAULT_FONT_COLOR) {
        String colorString = getRGBString(font.getXSSFColor());
        if (colorString != null) {
            return false;
        }/*from   w  ww. j  a v  a2  s  .  c o m*/
    }
    return true;
}

From source file:org.sysmodb.xml.XSSFXMLStyleHelper.java

License:BSD License

@Override
public void writeFontProperties(XMLStreamWriter xmlWriter, CellStyle style) throws XMLStreamException {
    XSSFCellStyle newStyle = (XSSFCellStyle) style;
    XSSFFont font = newStyle.getFont();
    if (font.getBold()) {
        xmlWriter.writeStartElement("font-weight");
        xmlWriter.writeCharacters("bold");
        xmlWriter.writeEndElement();/*from   www .  j  a v a 2  s  .c o m*/
    }
    if (font.getItalic()) {
        xmlWriter.writeStartElement("font-style");
        xmlWriter.writeCharacters("italics");
        xmlWriter.writeEndElement();
    }
    if (font.getUnderline() != XSSFFont.U_NONE) {
        xmlWriter.writeStartElement("text-decoration");
        xmlWriter.writeCharacters("underline");
        xmlWriter.writeEndElement();
    }
    if (font.getFontHeight() != XSSFFont.DEFAULT_FONT_SIZE) {
        xmlWriter.writeStartElement("font-size");
        xmlWriter.writeCharacters(String.valueOf(font.getFontHeightInPoints()) + "pt");
        xmlWriter.writeEndElement();
    }

    if (!font.getFontName().equals(XSSFFont.DEFAULT_FONT_NAME)) {
        xmlWriter.writeStartElement("font-family");
        xmlWriter.writeCharacters(String.valueOf(font.getFontName()));
        xmlWriter.writeEndElement();
    }
    if (font.getColor() != XSSFFont.DEFAULT_FONT_COLOR) {
        String colorString = getRGBString(font.getXSSFColor());
        if (colorString != null) {
            xmlWriter.writeStartElement("color");
            xmlWriter.writeCharacters(colorString);
            xmlWriter.writeEndElement();
        }
    }

}