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

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

Introduction

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

Prototype

public boolean getBold() 

Source Link

Document

get a boolean value for the boldness to use.

Usage

From source file:com.b2international.snowowl.datastore.server.importer.ExcelUtilities.java

License:Apache License

/**
 * Returns true if the cell (NOT the text inside) is set to bold.
 * @param cell/*from  w w  w .j  av  a 2 s. co  m*/
 * @return
 */
public static boolean isBold(Cell cell) {
    CellStyle style = cell.getCellStyle();
    Workbook workBook = cell.getSheet().getWorkbook();
    Font font = workBook.getFontAt(style.getFontIndex());
    XSSFFont xssfFont = (XSSFFont) font;
    return xssfFont.getBold();
}

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   www .  j  a  v a2s.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;
        }/* www. java 2  s .  co  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   w w  w  .j a v a2 s. com
    }
    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();
        }
    }

}