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

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

Introduction

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

Prototype

void setBorderBottom(BorderStyle border);

Source Link

Document

set the type of border to use for the bottom border of the cell

Usage

From source file:com.funtl.framework.smoke.core.commons.excel.ExportExcel.java

License:Apache License

/**
 * ?/* ww w  .j a v a  2 s .c  o m*/
 *
 * @param wb 
 * @return ?
 */
private Map<String, CellStyle> createStyles(Workbook wb) {
    Map<String, CellStyle> styles = new HashMap<String, CellStyle>();

    CellStyle style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    //      style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    //      style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    Font titleFont = wb.createFont();
    titleFont.setFontName("Arial");
    titleFont.setFontHeightInPoints((short) 16);
    titleFont.setBold(true);
    //      titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    style.setFont(titleFont);
    styles.put("title", style);

    style = wb.createCellStyle();
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    //      style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setBorderRight(BorderStyle.THIN);
    //      style.setBorderRight(CellStyle.BORDER_THIN);
    style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setBorderLeft(BorderStyle.THIN);
    //      style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setBorderTop(BorderStyle.THIN);
    //      style.setBorderTop(CellStyle.BORDER_THIN);
    style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setBorderBottom(BorderStyle.THIN);
    //      style.setBorderBottom(CellStyle.BORDER_THIN);
    style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    Font dataFont = wb.createFont();
    dataFont.setFontName("Arial");
    dataFont.setFontHeightInPoints((short) 10);
    style.setFont(dataFont);
    styles.put("data", style);

    style = wb.createCellStyle();
    style.cloneStyleFrom(styles.get("data"));
    style.setAlignment(HorizontalAlignment.LEFT);
    //      style.setAlignment(CellStyle.ALIGN_LEFT);
    styles.put("data1", style);

    style = wb.createCellStyle();
    style.cloneStyleFrom(styles.get("data"));
    style.setAlignment(HorizontalAlignment.CENTER);
    //      style.setAlignment(CellStyle.ALIGN_CENTER);
    styles.put("data2", style);

    style = wb.createCellStyle();
    style.cloneStyleFrom(styles.get("data"));
    style.setAlignment(HorizontalAlignment.RIGHT);
    //      style.setAlignment(CellStyle.ALIGN_RIGHT);
    styles.put("data3", style);

    style = wb.createCellStyle();
    style.cloneStyleFrom(styles.get("data"));
    //      style.setWrapText(true);
    style.setAlignment(HorizontalAlignment.CENTER);
    //      style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    //      style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    Font headerFont = wb.createFont();
    headerFont.setFontName("Arial");
    headerFont.setFontHeightInPoints((short) 10);
    headerFont.setBold(true);
    //      headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    headerFont.setColor(IndexedColors.WHITE.getIndex());
    style.setFont(headerFont);
    styles.put("header", style);

    return styles;
}

From source file:com.github.cutstock.excel.model.SheetBuilder.java

License:Apache License

private void initStyles() {
    CellStyle style;
    Workbook wb = sheet.getWorkbook();/*from   w  w w  .j a v a 2  s  .c  om*/

    Font titleFont = wb.createFont();
    titleFont.setFontHeightInPoints((short) 18);
    titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setFont(titleFont);
    styles.put("title", style);

    Font subTitle = wb.createFont();
    subTitle.setFontHeightInPoints((short) 12);
    subTitle.setBoldweight(Font.BOLDWEIGHT_BOLD);
    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_LEFT);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setFont(subTitle);
    styles.put("header", style);

    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_LEFT);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderTop(CellStyle.BORDER_THIN);
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderBottom(CellStyle.BORDER_THIN);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    styles.put("cell", style);

    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_LEFT);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderTop(CellStyle.BORDER_THIN);
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderBottom(CellStyle.BORDER_THIN);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    styles.put("highCell", style);

    style = wb.createCellStyle();
    Font imageTitle = wb.createFont();
    imageTitle.setFontHeightInPoints((short) 200);
    style.setFont(imageTitle);
    styles.put("image", style);

    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());
    style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    style.setDataFormat(wb.createDataFormat().getFormat("0.00"));
    styles.put("formula_2", style);

}

From source file:com.github.svrtm.xlreport.CellStyle_p.java

License:Apache License

public void copyTo(final CellStyle poiStyle) {
    if (verticalAlignment != null)
        poiStyle.setVerticalAlignment(verticalAlignment);
    if (alignment != null)
        poiStyle.setAlignment(alignment);

    if (borderBottom != null)
        poiStyle.setBorderBottom(borderBottom);
    if (bottomBorderColor != null)
        poiStyle.setBottomBorderColor(bottomBorderColor);
    if (borderLeft != null)
        poiStyle.setBorderLeft(borderLeft);
    if (leftBorderColor != null)
        poiStyle.setLeftBorderColor(leftBorderColor);
    if (borderRight != null)
        poiStyle.setBorderRight(borderRight);
    if (rightBorderColor != null)
        poiStyle.setRightBorderColor(rightBorderColor);
    if (borderTop != null)
        poiStyle.setBorderTop(borderTop);
    if (topBorderColor != null)
        poiStyle.setTopBorderColor(topBorderColor);

    if (wrapText != null)
        poiStyle.setWrapText(wrapText);/*from ww w  .jav a  2  s  . c o  m*/

    if (fillPattern != null)
        poiStyle.setFillPattern(fillPattern);
    if (xssfFgColor == null) {
        if (fillForegroundColor != null)
            poiStyle.setFillForegroundColor(fillForegroundColor);
    } else
        ((XSSFCellStyle) poiStyle).setFillForegroundColor(xssfFgColor);

    if (fmt != null)
        poiStyle.setDataFormat(fmt);
}

From source file:com.globalsight.everest.qachecks.DITAQAChecker.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("Times");
        font.setFontHeightInPoints((short) 11);

        CellStyle cs = p_workbook.createCellStyle();
        cs.setFont(font);//from w w  w . j a  va  2 s.co  m
        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.qachecks.QAChecker.java

License:Apache License

private CellStyle getHeaderStyle(Workbook p_workbook) {
    if (m_headerStyle == null) {
        Font font = p_workbook.createFont();
        font.setBoldweight(Font.BOLDWEIGHT_BOLD);
        font.setColor(IndexedColors.BLACK.getIndex());
        font.setUnderline(Font.U_NONE);
        font.setFontName("Times");
        font.setFontHeightInPoints((short) 11);

        CellStyle cs = p_workbook.createCellStyle();
        cs.setFont(font);/*from  w w  w .j a va 2s  . co  m*/
        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);

        m_headerStyle = cs;
    }

    return m_headerStyle;
}

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

License:Apache License

private CellStyle getHeaderStyle(Workbook p_workbook) {
    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("Times");
        font.setFontHeightInPoints((short) 11);

        CellStyle cs = p_workbook.createCellStyle();
        cs.setFont(font);//from w w w  .  j a  va 2 s .c  o  m
        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.generator.OnlineJobsReportForIPTranslatorGenerator.java

License:Apache License

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

        CellStyle cs = p_workbook.createCellStyle();
        cs.setFont(headerFont);/*  w  w  w. jav  a 2 s . co  m*/
        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.generator.OnlineJobsReportForIPTranslatorGenerator.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);//w w w .ja  v a2 s  .c om
        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.generator.OnlineJobsReportForIPTranslatorGenerator.java

License:Apache License

private CellStyle getTotalMoneyStyle(Workbook p_workbook) throws Exception {
    if (totalMoneyStyle == null) {
        String euroJavaNumberFormat = getCurrencyNumberFormat();
        DataFormat euroNumberFormat = p_workbook.createDataFormat();

        CellStyle cs = p_workbook.createCellStyle();
        cs.setDataFormat(euroNumberFormat.getFormat(euroJavaNumberFormat));
        cs.setWrapText(false);//ww w.ja  v a  2s .  com
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
        cs.setBorderTop(CellStyle.BORDER_THIN);
        cs.setBorderBottom(CellStyle.BORDER_THIN);

        totalMoneyStyle = cs;
    }
    return totalMoneyStyle;
}

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

License:Apache License

private void writeQualityAssessmentInfo(Workbook p_workbook, Sheet p_sheet, Job p_job,
        GlobalSightLocale p_targetLocale) throws Exception {
    String qualityAssessment = null;
    int col = 1;/*  w w  w .j a v a 2  s  .com*/
    int row = 6;
    CellStyle contentStyle = p_workbook.createCellStyle();
    contentStyle.cloneStyleFrom(getContentStyle(p_workbook));
    contentStyle.setBorderTop(CellStyle.BORDER_THIN);
    contentStyle.setBorderRight(CellStyle.BORDER_THIN);
    contentStyle.setBorderBottom(CellStyle.BORDER_THIN);
    contentStyle.setBorderLeft(CellStyle.BORDER_THIN);
    contentStyle.setLocked(false);
    Row langInfoRow = getRow(p_sheet, row);
    Cell qualityCell = getCell(langInfoRow, col++);
    for (Workflow wf : p_job.getWorkflows()) {
        if (p_targetLocale.getId() == wf.getTargetLocale().getId()) {
            Collection tasks = ServerProxy.getTaskManager().getCurrentTasks(wf.getId());
            if (tasks != null) {
                for (Iterator it = tasks.iterator(); it.hasNext();) {
                    Task task = (Task) it.next();
                    qualityAssessment = task.getQualityAssessment();
                }
            }
        }
    }
    if (qualityAssessment != null && !"".endsWith(qualityAssessment)) {
        qualityCell.setCellValue(qualityAssessment);
    } else {
        qualityCell.setCellValue("");
    }

    qualityCell.setCellStyle(contentStyle);

}