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

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

Introduction

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

Prototype

@Override
    public FillPatternType getFillPatternEnum() 

Source Link

Usage

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

License:Apache License

private void configureStyle(XSSFCellStyle style) {
    XSSFFont font = style.getFont();//from w  w  w.  j  av  a  2  s  . co  m
    if (font.getBold()) {
        _style.bold();
    }
    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.bbreak.excella.core.test.util.TestUtil.java

License:Open Source License

private static String getCellStyleString(XSSFCellStyle cellStyle) {
    StringBuffer sb = new StringBuffer();
    if (cellStyle != null) {
        XSSFFont font = cellStyle.getFont();
        sb.append("Font=").append(font.getCTFont()).append(",");
        sb.append("DataFormat=").append(cellStyle.getDataFormat()).append(",");
        sb.append("DataFormatString=").append(cellStyle.getDataFormatString()).append(",");
        sb.append("Hidden=").append(cellStyle.getHidden()).append(",");
        sb.append("Locked=").append(cellStyle.getLocked()).append(",");
        sb.append("Alignment=").append(cellStyle.getAlignmentEnum()).append(",");
        sb.append("WrapText=").append(cellStyle.getWrapText()).append(",");
        sb.append("VerticalAlignment=").append(cellStyle.getVerticalAlignmentEnum()).append(",");
        sb.append("Rotation=").append(cellStyle.getRotation()).append(",");
        sb.append("Indention=").append(cellStyle.getIndention()).append(",");
        sb.append("BorderLeft=").append(cellStyle.getBorderLeftEnum()).append(",");
        sb.append("BorderRight=").append(cellStyle.getBorderRightEnum()).append(",");
        sb.append("BorderTop=").append(cellStyle.getBorderTopEnum()).append(",");
        sb.append("BorderBottom=").append(cellStyle.getBorderBottomEnum()).append(",");

        sb.append("LeftBorderColor=").append(getXSSFColorString(cellStyle.getLeftBorderXSSFColor()))
                .append(",");
        sb.append("RightBorderColor=").append(getXSSFColorString(cellStyle.getRightBorderXSSFColor()))
                .append(",");
        sb.append("TopBorderColor=").append(getXSSFColorString(cellStyle.getTopBorderXSSFColor())).append(",");
        sb.append("BottomBorderColor=").append(getXSSFColorString(cellStyle.getBottomBorderXSSFColor()))
                .append(",");

        sb.append("FillPattern=").append(cellStyle.getFillPatternEnum()).append(",");
        sb.append("FillForegroundColor=").append(getXSSFColorString(cellStyle.getFillForegroundXSSFColor()))
                .append(",");
        sb.append("FillBackgroundColor=").append(getXSSFColorString(cellStyle.getFillBackgroundXSSFColor()));
    }/* w  ww .  ja va 2  s .c  om*/
    return sb.toString();
}

From source file:org.bbreak.excella.reports.ReportsTestUtil.java

License:Open Source License

/**
 * XSSF????/*from   w w w.j a va 2s .com*/
 * 
 * @param cellStyle 
 * @return ??
 */
private static String getCellStyleString(XSSFCellStyle cellStyle) {
    StringBuffer sb = new StringBuffer();
    if (cellStyle != null) {
        XSSFFont font = cellStyle.getFont();
        sb.append("Font=").append(font.getCTFont()).append(",");
        sb.append("DataFormat=").append(cellStyle.getDataFormat()).append(",");
        sb.append("DataFormatString=").append(cellStyle.getDataFormatString()).append(",");
        sb.append("Hidden=").append(cellStyle.getHidden()).append(",");
        sb.append("Locked=").append(cellStyle.getLocked()).append(",");
        sb.append("Alignment=").append(cellStyle.getAlignmentEnum()).append(",");
        sb.append("WrapText=").append(cellStyle.getWrapText()).append(",");
        sb.append("VerticalAlignment=").append(cellStyle.getVerticalAlignmentEnum()).append(",");
        sb.append("Rotation=").append(cellStyle.getRotation()).append(",");
        sb.append("Indention=").append(cellStyle.getIndention()).append(",");
        sb.append("BorderLeft=").append(cellStyle.getBorderLeftEnum()).append(",");
        sb.append("BorderRight=").append(cellStyle.getBorderRightEnum()).append(",");
        sb.append("BorderTop=").append(cellStyle.getBorderTopEnum()).append(",");
        sb.append("BorderBottom=").append(cellStyle.getBorderBottomEnum()).append(",");

        sb.append("LeftBorderColor=").append(getXSSFColorString(cellStyle.getLeftBorderXSSFColor()))
                .append(",");
        sb.append("RightBorderColor=").append(getXSSFColorString(cellStyle.getRightBorderXSSFColor()))
                .append(",");
        sb.append("TopBorderColor=").append(getXSSFColorString(cellStyle.getTopBorderXSSFColor())).append(",");
        sb.append("BottomBorderColor=").append(getXSSFColorString(cellStyle.getBottomBorderXSSFColor()))
                .append(",");

        sb.append("FillPattern=").append(cellStyle.getFillPatternEnum()).append(",");
        try {
            sb.append("FillForegroundColor=").append(getXSSFColorString(cellStyle.getFillForegroundXSSFColor()))
                    .append(",");
        } catch (NullPointerException e) {
            // POI-3.7???
            sb.append("FillForegroundColor=none,");
        }

        try {
            sb.append("FillBackgroundColor=")
                    .append(getXSSFColorString(cellStyle.getFillBackgroundXSSFColor()));
        } catch (NullPointerException e) {
            // POI-3.7???
            sb.append("FillBackgroundColor=none,");
        }
    }
    return sb.toString();
}