Example usage for org.apache.poi.xssf.usermodel XSSFCellStyle getFontIndex

List of usage examples for org.apache.poi.xssf.usermodel XSSFCellStyle getFontIndex

Introduction

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

Prototype

@Override
@Deprecated
public short getFontIndex() 

Source Link

Document

Gets the index of the font for this style

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 av a 2s  . c  om*/

        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;
}