Example usage for org.apache.poi.ss.usermodel CellStyle setFillPattern

List of usage examples for org.apache.poi.ss.usermodel CellStyle setFillPattern

Introduction

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

Prototype

void setFillPattern(FillPatternType fp);

Source Link

Document

setting to one fills the cell with the foreground color...

Usage

From source file:com.canoo.webtest.plugins.exceltest.ExcelVerifyCellStyleTest.java

License:Open Source License

public void testUnknownProperties() throws Exception {
    final ExcelVerifyCellStyle step = (ExcelVerifyCellStyle) getStep();
    step.setCell("B2");
    final CellStyle cellStyle = step.getExcelCell().getCellStyle();
    cellStyle.setBorderTop(Short.MAX_VALUE);
    cellStyle.setAlignment(Short.MAX_VALUE);
    cellStyle.setVerticalAlignment(Short.MAX_VALUE);
    cellStyle.setFillPattern(Short.MAX_VALUE);
    final Font fontAt = step.getExcelWorkbook().getFontAt(cellStyle.getFontIndex());
    fontAt.setUnderline(Byte.MAX_VALUE);
    step.setBorder("top:unknown");
    step.setAlign("unknown");
    step.setValign("unknown");
    step.setFillPattern("unknown");
    step.setFontStyle("bold underline-unknown");
    executeStep(step);//w w  w.j  ava 2  s . com
}

From source file:com.catexpress.util.FormatosPOI.java

public CellStyle estiloVacio(Workbook wb) {
    CellStyle estiloCelda = wb.createCellStyle();
    estiloCelda.setFillForegroundColor(IndexedColors.WHITE.getIndex());
    estiloCelda.setFillPattern(CellStyle.SOLID_FOREGROUND);
    return estiloCelda;
}

From source file:com.catexpress.util.FormatosPOI.java

public CellStyle estiloColumnas(Workbook wb, int tipo) {
    CellStyle estiloCelda = wb.createCellStyle();
    Font fuente = wb.createFont();
    if (tipo == COLUMNA) {
        estiloCelda.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
        estiloCelda.setFillPattern(CellStyle.SOLID_FOREGROUND);
        fuente.setBold(true);//from w ww .j a v  a 2s. c o  m
    }
    if (tipo == SURTIDO) {
        fuente.setColor(IndexedColors.WHITE.getIndex());
        estiloCelda.setFillForegroundColor(IndexedColors.ROYAL_BLUE.getIndex());
        estiloCelda.setFillPattern(CellStyle.SOLID_FOREGROUND);
    }
    fuente.setFontName("Calibri");
    fuente.setFontHeightInPoints((short) 11);
    estiloCelda.setFont(fuente);
    estiloCelda.setVerticalAlignment(VerticalAlignment.CENTER);
    estiloCelda.setAlignment(HorizontalAlignment.CENTER);
    if (tipo == COLUMNA) {
        estiloCelda.setBorderBottom(BorderStyle.MEDIUM);
        estiloCelda.setBorderTop(BorderStyle.MEDIUM);
        estiloCelda.setBorderLeft(BorderStyle.MEDIUM);
        estiloCelda.setBorderRight(BorderStyle.MEDIUM);
    } else {
        estiloCelda.setBorderBottom(BorderStyle.THIN);
        estiloCelda.setBorderTop(BorderStyle.THIN);
        estiloCelda.setBorderLeft(BorderStyle.THIN);
        estiloCelda.setBorderRight(BorderStyle.THIN);
    }
    return estiloCelda;
}

From source file:com.catexpress.util.FormatosPOI.java

public CellStyle estiloTotales(Workbook wb) {
    CellStyle estiloCelda = wb.createCellStyle();
    Font fuente = wb.createFont();
    estiloCelda.setFillForegroundColor(IndexedColors.ROYAL_BLUE.getIndex());
    estiloCelda.setFillPattern(CellStyle.SOLID_FOREGROUND);
    fuente.setFontName("Calibri");
    fuente.setBold(true);/*from w  ww.j av  a 2  s . c  o  m*/
    fuente.setFontHeightInPoints((short) 14);
    fuente.setColor(IndexedColors.WHITE.getIndex());
    estiloCelda.setFont(fuente);
    estiloCelda.setVerticalAlignment(VerticalAlignment.CENTER);
    estiloCelda.setAlignment(HorizontalAlignment.CENTER);
    estiloCelda.setBorderBottom(BorderStyle.MEDIUM);
    estiloCelda.setBorderTop(BorderStyle.MEDIUM);
    estiloCelda.setBorderLeft(BorderStyle.MEDIUM);
    estiloCelda.setBorderRight(BorderStyle.MEDIUM);

    return estiloCelda;
}

From source file:com.catexpress.util.FormatosPOI.java

public CellStyle estiloCuadro(Workbook wb, int tipo) {
    CellStyle estiloCelda = wb.createCellStyle();
    Font fuente = wb.createFont();
    if (tipo == AMARILLO) {
        estiloCelda.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
        estiloCelda.setFillPattern(CellStyle.SOLID_FOREGROUND);
    }//from  w  w  w.j  av  a 2  s . com
    fuente.setFontName("Calibri");
    fuente.setBold(true);
    fuente.setFontHeightInPoints((short) 12);
    estiloCelda.setFont(fuente);
    estiloCelda.setVerticalAlignment(VerticalAlignment.CENTER);
    estiloCelda.setAlignment(HorizontalAlignment.CENTER);
    estiloCelda.setBorderBottom(BorderStyle.THIN);
    estiloCelda.setBorderTop(BorderStyle.THIN);
    estiloCelda.setBorderLeft(BorderStyle.THIN);
    estiloCelda.setBorderRight(BorderStyle.THIN);

    return estiloCelda;
}

From source file:com.catexpress.util.FormatosPOI.java

public CellStyle estiloHeader(Workbook wb, int tipo) {
    Font fuente = wb.createFont();
    CreationHelper createHelper = wb.getCreationHelper();
    fuente.setFontName("Calibri");
    fuente.setBold(true);/*w  ww .  ja v a2s  .  c  o m*/

    if (tipo == TITULO || tipo == SUCURSAL || tipo == LABEL || tipo == FECHA) {
        fuente.setFontHeightInPoints((short) 16);
    } else if (tipo == USUARIO) {
        fuente.setFontHeightInPoints((short) 20);
    }

    CellStyle estiloCelda = wb.createCellStyle();
    estiloCelda.setFont(fuente);

    if (tipo == TITULO || tipo == USUARIO || tipo == LABEL || tipo == FECHA) {
        estiloCelda.setFillForegroundColor(IndexedColors.WHITE.getIndex());
    } else if (tipo == SUCURSAL) {
        estiloCelda.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
    }
    estiloCelda.setFillPattern(CellStyle.SOLID_FOREGROUND);

    if (tipo == LABEL || tipo == FECHA) {
        estiloCelda.setWrapText(false);
    } else if (tipo == TITULO || tipo == SUCURSAL || tipo == USUARIO) {
        estiloCelda.setWrapText(true);
    }

    estiloCelda.setAlignment(HorizontalAlignment.CENTER);

    if (tipo == LABEL || tipo == FECHA) {
        estiloCelda.setVerticalAlignment(VerticalAlignment.BOTTOM);
    } else if (tipo == TITULO || tipo == SUCURSAL || tipo == USUARIO) {
        estiloCelda.setVerticalAlignment(VerticalAlignment.CENTER);
    }

    if (tipo == SUCURSAL) {
        estiloCelda.setBorderBottom(BorderStyle.MEDIUM);
        estiloCelda.setBorderTop(BorderStyle.MEDIUM);
        estiloCelda.setBorderLeft(BorderStyle.MEDIUM);
        estiloCelda.setBorderRight(BorderStyle.MEDIUM);
    }

    if (tipo == FECHA) {
        estiloCelda.setDataFormat(createHelper.createDataFormat().getFormat("dd \"de\" mmmm \"de\" yyyy"));
    }

    return estiloCelda;
}

From source file:com.cms.utils.ExportExcellCelltype.java

public CellStyle cellTypeColumnStt() {
    CellStyle cellStyle = wb.createCellStyle();
    cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
    cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
    cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
    cellStyle.setBorderRight(CellStyle.BORDER_THIN);
    cellStyle.setBorderTop(CellStyle.BORDER_THIN);
    cellStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
    cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    cellStyle.setWrapText(false);/* w w w  . j  a  va 2  s. c om*/
    return cellStyle;

}

From source file:com.cms.utils.ExportExcellCelltype.java

public CellStyle cellTypeHeader(Boolean wraptext) {
    CellStyle cellStyle = wb.createCellStyle();
    cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
    cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
    cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
    cellStyle.setBorderRight(CellStyle.BORDER_THIN);
    cellStyle.setBorderTop(CellStyle.BORDER_THIN);
    cellStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
    cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    cellStyle.setWrapText(wraptext);//from   w w  w  . j a va2s.  c  om
    return cellStyle;
}

From source file:com.dituiba.excel.BaseExcelService.java

License:Apache License

/**
 * ?//from  w w  w.  j av a2s.c  o  m
 * @param cell
 */
public static void setErrorStyle(Cell cell) {
    if (cell != null) {
        CellStyle newstyle = cell.getSheet().getWorkbook().createCellStyle();
        CellStyle style = cell.getCellStyle();
        if (style != null) {
            newstyle.cloneStyleFrom(style);
        }
        newstyle.setFillForegroundColor(IndexedColors.RED.getIndex());
        newstyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cell.setCellStyle(newstyle);
    }
}

From source file:com.diversityarrays.kdxplore.exportdata.CellStyleProvider.java

License:Open Source License

public CellStyle getCellStyle(BmsCellColor bmsCellColor) {

    CellStyle result = styleByBmsCellColor.get(bmsCellColor);

    if (result == null) {

        result = workbook.createCellStyle();

        result.setFillPattern(CellStyle.SOLID_FOREGROUND);
        result.setFillForegroundColor(bmsCellColor.indexedColor.getIndex());

        Font font = workbook.createFont();
        font.setColor(IndexedColors.WHITE.getIndex());
        result.setFont(font);/*from w  w w  .ja v a  2s  .c  om*/

        styleByBmsCellColor.put(bmsCellColor, result);
    }

    return result;
}