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.globalsight.everest.webapp.pagehandler.administration.reports.JobAttributeReportHelper.java

License:Apache License

private CellStyle getHeaderStyle(Boolean isSuper) throws Exception {
    if (isSuper && headerStyleSuper != null) {
        return headerStyleSuper;
    }//from  w w w. ja  v a2  s.  co  m

    if (!isSuper && headerStyle != null) {
        return headerStyle;
    }

    Font font = workbook.createFont();
    font.setBoldweight(Font.BOLDWEIGHT_BOLD);
    if (isSuper) {
        font.setColor(IndexedColors.ORANGE.getIndex());
    } else {
        font.setColor(IndexedColors.BLACK.getIndex());
    }
    font.setUnderline(Font.U_NONE);
    font.setFontName("Arial");
    font.setFontHeightInPoints((short) 9);

    CellStyle cs = workbook.createCellStyle();
    cs.setFont(font);
    cs.setWrapText(true);
    cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
    cs.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
    cs.setBorderTop(CellStyle.BORDER_THIN);
    cs.setBorderRight(CellStyle.BORDER_THIN);
    cs.setBorderBottom(CellStyle.BORDER_THIN);
    cs.setBorderLeft(CellStyle.BORDER_THIN);

    if (isSuper) {
        headerStyleSuper = cs;
        return headerStyleSuper;
    } else {
        headerStyle = cs;
        return headerStyle;
    }
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.JobStatusXlsReportProcessor.java

License:Apache License

private CellStyle getRedStyle(Workbook p_workbook) throws Exception {
    if (redStyle == null) {
        Font redFont = p_workbook.createFont();
        redFont.setFontName("Arial");
        redFont.setUnderline(Font.U_NONE);
        redFont.setFontHeightInPoints((short) 10);

        CellStyle style = p_workbook.createCellStyle();
        style.setFont(redFont);//w w w  .  j  a  v  a2  s .c  o m
        style.setWrapText(true);
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        style.setFillForegroundColor(IndexedColors.RED.getIndex());

        redStyle = style;
    }

    return redStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.ReviewerVendorPoXlsReportHelper.java

License:Apache License

private CellStyle getSubTotalStyle(Workbook p_workbook) throws Exception {
    if (subTotalStyle == null) {
        Font subTotalFont = p_workbook.createFont();
        subTotalFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
        subTotalFont.setColor(IndexedColors.BLACK.getIndex());
        subTotalFont.setUnderline(Font.U_NONE);
        subTotalFont.setFontName("Arial");
        subTotalFont.setFontHeightInPoints((short) 10);

        CellStyle cs = p_workbook.createCellStyle();
        cs.setFont(subTotalFont);/*from   w  w w.jav  a2 s.  com*/
        cs.setWrapText(true);
        cs.setBorderTop(CellStyle.BORDER_THIN);
        cs.setBorderBottom(CellStyle.BORDER_THIN);
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());

        subTotalStyle = cs;
    }

    return subTotalStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.ReviewerVendorPoXlsReportHelper.java

License:Apache License

private CellStyle getTotalMoneyStyle(Workbook p_workbook) throws Exception {
    if (totalMoneyStyle == null) {
        DataFormat euroNumberFormat = p_workbook.createDataFormat();
        CellStyle cs = p_workbook.createCellStyle();
        cs.setDataFormat(euroNumberFormat.getFormat(CurrencyThreadLocal.getMoneyFormatString()));
        cs.setWrapText(false);/*from   www  .  ja  va 2s  . c om*/
        cs.setBorderTop(CellStyle.BORDER_THIN);
        cs.setBorderBottom(CellStyle.BORDER_THIN);
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());

        totalMoneyStyle = cs;
    }

    return totalMoneyStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.SlaXlsReportHelper.java

License:Apache License

private CellStyle getHeaderStyle(Workbook p_workbook) throws Exception {
    if (headerStyle == null) {
        Font font = p_workbook.createFont();
        font.setBoldweight(Font.BOLDWEIGHT_BOLD);
        font.setColor(IndexedColors.BLACK.getIndex());
        font.setUnderline(Font.U_NONE);
        font.setFontName("Arial");
        font.setFontHeightInPoints((short) 9);

        CellStyle cs = p_workbook.createCellStyle();
        cs.setFont(font);//from   w  w w  .ja va 2s. c om
        cs.setWrapText(true);
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
        cs.setBorderTop(CellStyle.BORDER_THIN);
        cs.setBorderRight(CellStyle.BORDER_THIN);
        cs.setBorderBottom(CellStyle.BORDER_THIN);
        cs.setBorderLeft(CellStyle.BORDER_THIN);

        headerStyle = cs;
    }

    return headerStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.VendorPOXlsReport.java

License:Apache License

private CellStyle getRedCellStyle(Workbook p_workbook) throws Exception {
    if (redCellStyle == null) {
        Font redFont = p_workbook.createFont();
        redFont.setFontName("Arial");
        redFont.setUnderline(Font.U_NONE);
        redFont.setFontHeightInPoints((short) 10);

        CellStyle style = p_workbook.createCellStyle();
        style.setFont(redFont);//from   w ww. j a  va 2 s.  c o  m
        style.setWrapText(true);
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        style.setFillForegroundColor(IndexedColors.RED.getIndex());

        redCellStyle = style;
    }
    return redCellStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.VendorPOXlsReport.java

License:Apache License

private CellStyle getFailedDateStyle(Workbook p_workbook) throws Exception {
    if (failedDateStyle == null) {
        Font dateFont = p_workbook.createFont();
        dateFont.setFontName("Arial");
        dateFont.setFontHeightInPoints((short) 10);

        DataFormat format = p_workbook.createDataFormat();
        CellStyle cs = p_workbook.createCellStyle();
        cs.setFont(dateFont);//w w  w.  j  a  v a  2  s  . com
        cs.setDataFormat(format.getFormat("M/d/yy"));
        cs.setWrapText(false);
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.RED.getIndex());

        failedDateStyle = cs;
    }
    return failedDateStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.VendorPOXlsReport.java

License:Apache License

private CellStyle getFailedMoneyStyle(Workbook p_workbook) throws Exception {
    if (failedMoneyStyle == null) {
        String euroJavaNumberFormat = getNumberFormatString();
        DataFormat euroNumberFormat = p_workbook.createDataFormat();

        CellStyle cs = p_workbook.createCellStyle();
        cs.setWrapText(false);//from   w  w w  .  ja  va2 s.c  o  m
        cs.setDataFormat(euroNumberFormat.getFormat(euroJavaNumberFormat));
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.RED.getIndex());

        failedMoneyStyle = cs;
    }
    return failedMoneyStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.VendorPOXlsReport.java

License:Apache License

private CellStyle getTotalMoneyStyle(Workbook p_workbook) throws Exception {
    if (totalMoneyStyle == null) {
        String euroJavaNumberFormat = getNumberFormatString();
        DataFormat euroNumberFormat = p_workbook.createDataFormat();
        CellStyle cs = p_workbook.createCellStyle();
        cs.setDataFormat(euroNumberFormat.getFormat(euroJavaNumberFormat));
        cs.setWrapText(false);/*w  w w.j a v a  2s .  com*/
        cs.setBorderTop(CellStyle.BORDER_THIN);
        cs.setBorderBottom(CellStyle.BORDER_THIN);
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());

        totalMoneyStyle = cs;
    }
    return totalMoneyStyle;
}

From source file:com.griffinslogistics.document.excel.BDLGenerator.java

private static Map<String, CellStyle> createStyles(Workbook workbook) {
    Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
    CellStyle style;
    Font titleFont = workbook.createFont();
    titleFont.setFontHeightInPoints((short) 26);
    titleFont.setFontName("Calibri");
    titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    style = workbook.createCellStyle();/* w  w  w.j a  v  a2s.  c om*/
    style.setFont(titleFont);
    style.setAlignment(CellStyle.ALIGN_CENTER);
    styles.put("title", style);

    titleFont = workbook.createFont();
    titleFont.setFontHeightInPoints((short) 18);
    titleFont.setFontName("Calibri");
    style = workbook.createCellStyle();
    style.setFont(titleFont);
    style.setAlignment(CellStyle.ALIGN_JUSTIFY);

    styles.put("pulsioName", style);

    titleFont = workbook.createFont();
    titleFont.setFontHeightInPoints((short) 14);
    titleFont.setFontName("Calibri");
    style = workbook.createCellStyle();
    style.setFont(titleFont);
    style.setAlignment(CellStyle.ALIGN_JUSTIFY);

    styles.put("contacts", style);

    CellStyle footerStyle = workbook.createCellStyle();
    Font footerFont = workbook.createFont();
    footerFont.setFontHeightInPoints((short) 14);
    footerFont.setFontName("Calibri");
    footerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    footerStyle.setFont(footerFont);
    footerStyle.setAlignment(CellStyle.ALIGN_JUSTIFY);

    styles.put("footer", footerStyle);

    titleFont = workbook.createFont();
    titleFont.setFontHeightInPoints((short) 14);
    titleFont.setFontName("Calibri");
    titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    titleFont.setItalic(true);
    style = workbook.createCellStyle();
    style.setFont(titleFont);
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setWrapText(true);

    style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
    style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    style.setBorderLeft(CellStyle.BORDER_MEDIUM);
    style.setBorderTop(CellStyle.BORDER_MEDIUM);
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setBorderBottom(CellStyle.BORDER_THIN);

    styles.put("tableHeadersLeft", style);

    CellStyle headerRowMiddleCellStyle = workbook.createCellStyle();
    headerRowMiddleCellStyle.cloneStyleFrom(style);
    headerRowMiddleCellStyle.setBorderLeft(CellStyle.BORDER_THIN);

    styles.put("tableHeadersMiddle", headerRowMiddleCellStyle);

    CellStyle headerRowRightCellStyle = workbook.createCellStyle();
    headerRowRightCellStyle.cloneStyleFrom(style);
    headerRowRightCellStyle.setBorderRight(CellStyle.BORDER_MEDIUM);

    styles.put("tableHeadersRight", headerRowRightCellStyle);

    CellStyle footerRowRightCellStyle = workbook.createCellStyle();
    footerRowRightCellStyle.cloneStyleFrom(style);
    footerRowRightCellStyle.setFillPattern(CellStyle.NO_FILL);
    footerRowRightCellStyle.setBorderRight(CellStyle.BORDER_MEDIUM);
    footerRowRightCellStyle.setBorderBottom(CellStyle.BORDER_MEDIUM);

    styles.put("tableFooters", footerRowRightCellStyle);

    CellStyle bodyRowLeftCellStyle = workbook.createCellStyle();
    bodyRowLeftCellStyle.cloneStyleFrom(style);
    Font titleBodyFont = workbook.createFont();
    titleBodyFont.setFontHeightInPoints((short) 14);
    titleBodyFont.setFontName("Calibri");
    bodyRowLeftCellStyle.setFont(titleBodyFont);
    bodyRowLeftCellStyle.setBorderTop(CellStyle.BORDER_THIN);
    bodyRowLeftCellStyle.setFillPattern(CellStyle.NO_FILL);

    styles.put("tableBodyLeft", bodyRowLeftCellStyle);

    CellStyle bodyRowMiddleCellStyle = workbook.createCellStyle();
    bodyRowMiddleCellStyle.cloneStyleFrom(bodyRowLeftCellStyle);
    bodyRowMiddleCellStyle.setBorderLeft(CellStyle.BORDER_THIN);

    styles.put("tableBodyMiddle", bodyRowMiddleCellStyle);

    CellStyle bodyRowRightCellStyle = workbook.createCellStyle();
    bodyRowRightCellStyle.cloneStyleFrom(bodyRowMiddleCellStyle);
    bodyRowRightCellStyle.setBorderRight(CellStyle.BORDER_MEDIUM);

    styles.put("tableBodyRight", bodyRowRightCellStyle);

    return styles;
}