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

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

Introduction

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

Prototype

@Override
public void setWrapText(boolean wrapped) 

Source Link

Document

Set whether the text should be wrapped.

Usage

From source file:com.netsteadfast.greenstep.bsc.command.OrganizationReportExcelCommand.java

License:Apache License

private int createHead(XSSFWorkbook wb, XSSFSheet sh, int row, VisionVO vision, Context context)
        throws Exception {
    String dateType = (String) context.get("dateType");
    String year = (String) context.get("startYearDate");
    String orgId = (String) context.get("orgId");
    String departmentName = "";
    String dateTypeName = "Year";
    if ("1".equals(dateType)) {
        dateTypeName = "In the first half";
    }/*from   w w w.  j a  v  a2 s  .  co  m*/
    if ("2".equals(dateType)) {
        dateTypeName = "In the second half";
    }
    OrganizationVO organization = new OrganizationVO();
    organization.setOrgId(orgId);
    DefaultResult<OrganizationVO> result = this.organizationService.findByUK(organization);
    if (result.getValue() != null) {
        organization = result.getValue();
        departmentName = organization.getName();
    }

    Row headRow = sh.createRow(row);
    headRow.setHeight((short) 700);

    XSSFColor bgColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor("#F2F2F2"));
    XSSFColor fnColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor("#000000"));

    XSSFCellStyle cellHeadStyle = wb.createCellStyle();
    cellHeadStyle.setFillForegroundColor(bgColor);
    cellHeadStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

    XSSFFont cellHeadFont = wb.createFont();
    cellHeadFont.setBold(true);
    cellHeadFont.setColor(fnColor);
    cellHeadStyle.setFont(cellHeadFont);
    cellHeadStyle.setBorderBottom(BorderStyle.THIN);
    cellHeadStyle.setBorderTop(BorderStyle.THIN);
    cellHeadStyle.setBorderRight(BorderStyle.THIN);
    cellHeadStyle.setBorderLeft(BorderStyle.THIN);
    cellHeadStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    cellHeadStyle.setAlignment(HorizontalAlignment.CENTER);
    cellHeadStyle.setWrapText(true);

    int cols = 6;
    for (int i = 0; i < cols; i++) {
        sh.setColumnWidth(i, 6000);
        Cell headCell1 = headRow.createCell(i);
        headCell1.setCellValue("Personal Balance SourceCard");
        headCell1.setCellStyle(cellHeadStyle);
    }
    sh.addMergedRegion(new CellRangeAddress(row, row, 0, cols - 1));

    row++;
    headRow = sh.createRow(row);
    for (int i = 0; i < cols; i++) {
        sh.setColumnWidth(i, 6000);
        Cell headCell1 = headRow.createCell(i);
        headCell1.setCellValue(vision.getTitle());
        headCell1.setCellStyle(cellHeadStyle);
    }
    sh.addMergedRegion(new CellRangeAddress(row, row, 0, cols - 1));

    row++;
    headRow = sh.createRow(row);

    Cell titleCell1 = headRow.createCell(0);
    titleCell1.setCellValue("Department");
    titleCell1.setCellStyle(cellHeadStyle);

    Cell titleCell2 = headRow.createCell(1);
    titleCell2.setCellValue(departmentName);
    titleCell2.setCellStyle(cellHeadStyle);

    Cell titleCell3 = headRow.createCell(2);
    titleCell3.setCellValue(departmentName);
    titleCell3.setCellStyle(cellHeadStyle);

    Cell titleCell4 = headRow.createCell(3);
    titleCell4.setCellValue(departmentName);
    titleCell4.setCellStyle(cellHeadStyle);

    Cell titleCell5 = headRow.createCell(4);
    titleCell5.setCellValue(departmentName);
    titleCell5.setCellStyle(cellHeadStyle);

    Cell titleCell6 = headRow.createCell(5);
    titleCell6.setCellValue(year + " " + dateTypeName);
    titleCell6.setCellStyle(cellHeadStyle);

    sh.addMergedRegion(new CellRangeAddress(row, row, 1, cols - 2));

    row++;
    headRow = sh.createRow(row);

    titleCell1 = headRow.createCell(0);
    titleCell1.setCellValue(BscReportPropertyUtils.getPerspectiveTitle());
    titleCell1.setCellStyle(cellHeadStyle);

    titleCell2 = headRow.createCell(1);
    titleCell2.setCellValue(BscReportPropertyUtils.getObjectiveTitle());
    titleCell2.setCellStyle(cellHeadStyle);

    titleCell3 = headRow.createCell(2);
    titleCell3.setCellValue(BscReportPropertyUtils.getKpiTitle());
    titleCell3.setCellStyle(cellHeadStyle);

    titleCell4 = headRow.createCell(3);
    titleCell4.setCellValue("Weight");
    titleCell4.setCellStyle(cellHeadStyle);

    titleCell5 = headRow.createCell(4);
    titleCell5.setCellValue("Maximum\nTarget\nMinimum");
    titleCell5.setCellStyle(cellHeadStyle);

    titleCell6 = headRow.createCell(5);
    titleCell6.setCellValue("Score");
    titleCell6.setCellStyle(cellHeadStyle);

    row = row + 1;
    return row;
}

From source file:com.netsteadfast.greenstep.bsc.command.OrganizationReportExcelCommand.java

License:Apache License

private int createMainBody(XSSFWorkbook wb, XSSFSheet sh, int row, VisionVO vision) throws Exception {

    XSSFCellStyle cellStyle = wb.createCellStyle();
    cellStyle.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#ffffff")));
    cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    XSSFFont cellFont = wb.createFont();
    cellFont.setBold(false);//w  w  w.  j a v  a 2s  .c  o  m
    cellFont.setColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#000000")));
    cellStyle.setFont(cellFont);
    cellStyle.setWrapText(true);
    cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    cellStyle.setBorderBottom(BorderStyle.THIN);
    cellStyle.setBorderTop(BorderStyle.THIN);
    cellStyle.setBorderRight(BorderStyle.THIN);
    cellStyle.setBorderLeft(BorderStyle.THIN);

    int mrRow = row;
    for (int px = 0; px < vision.getPerspectives().size(); px++) {
        PerspectiveVO perspective = vision.getPerspectives().get(px);

        for (int ox = 0; ox < perspective.getObjectives().size(); ox++) {
            ObjectiveVO objective = perspective.getObjectives().get(ox);

            for (int kx = 0; kx < objective.getKpis().size(); kx++) {
                KpiVO kpi = objective.getKpis().get(kx);
                Row contentRow = sh.createRow(row++);

                Cell cell1 = contentRow.createCell(0);
                cell1.setCellValue(perspective.getName());
                cell1.setCellStyle(cellStyle);

                Cell titleCell2 = contentRow.createCell(1);
                titleCell2.setCellValue(objective.getName());
                titleCell2.setCellStyle(cellStyle);

                Cell titleCell3 = contentRow.createCell(2);
                titleCell3.setCellValue(kpi.getName());
                titleCell3.setCellStyle(cellStyle);

                Cell titleCell4 = contentRow.createCell(3);
                titleCell4.setCellValue(kpi.getWeight() + "%");
                titleCell4.setCellStyle(cellStyle);

                Cell titleCell5 = contentRow.createCell(4);
                titleCell5.setCellValue("max: " + kpi.getMax() + "\n" + "target: " + kpi.getTarget() + "\n"
                        + "min: " + kpi.getMin() + "\n" + "unit: " + kpi.getUnit());
                titleCell5.setCellStyle(cellStyle);

                DateRangeScoreVO dateRangeScore = kpi.getDateRangeScores().get(0);

                XSSFCellStyle cellStyle2 = wb.createCellStyle();
                cellStyle2.setFillForegroundColor(
                        new XSSFColor(SimpleUtils.getColorRGB4POIColor(dateRangeScore.getBgColor())));
                cellStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
                XSSFFont cellFont2 = wb.createFont();
                cellFont2.setBold(false);
                cellFont2.setColor(
                        new XSSFColor(SimpleUtils.getColorRGB4POIColor(dateRangeScore.getFontColor())));
                cellStyle2.setFont(cellFont2);
                cellStyle2.setWrapText(true);
                cellStyle2.setVerticalAlignment(VerticalAlignment.CENTER);
                cellStyle2.setBorderBottom(BorderStyle.THIN);
                cellStyle2.setBorderTop(BorderStyle.THIN);
                cellStyle2.setBorderRight(BorderStyle.THIN);
                cellStyle2.setBorderLeft(BorderStyle.THIN);

                Cell titleCell6 = contentRow.createCell(5);
                titleCell6.setCellValue(BscReportSupportUtils.parse2(dateRangeScore.getScore()));
                titleCell6.setCellStyle(cellStyle2);

            }
        }
    }

    for (int px = 0; px < vision.getPerspectives().size(); px++) {
        PerspectiveVO perspective = vision.getPerspectives().get(px);
        // 2016-12-13 old work with POI 3.12
        //sh.addMergedRegion(new CellRangeAddress(mrRow, mrRow + perspective.getRow()-1, 0, 0));

        // 2016-12-13 new work with POI 3.15
        int mrRow1 = mrRow + perspective.getRow() - 1;
        if (mrRow1 > mrRow) {
            sh.addMergedRegion(new CellRangeAddress(mrRow, mrRow1, 0, 0));
        }

        for (int ox = 0; ox < perspective.getObjectives().size(); ox++) {
            ObjectiveVO objective = perspective.getObjectives().get(ox);
            // 2016-12-13 old work with POI 3.12
            //sh.addMergedRegion(new CellRangeAddress(mrRow, mrRow + objective.getRow()-1, 1, 1));

            // 2016-12-13 new work with POI 3.15
            int mrRow2 = mrRow + objective.getRow() - 1;
            if (mrRow2 > mrRow) {
                sh.addMergedRegion(new CellRangeAddress(mrRow, mrRow2, 1, 1));
            }

            mrRow += objective.getKpis().size();
        }

    }

    return row++;
}

From source file:com.netsteadfast.greenstep.bsc.command.PdcaReportExcelCommand.java

License:Apache License

private int createPdca(XSSFWorkbook wb, XSSFSheet sh, int row, Context context) throws Exception {

    PdcaVO pdca = (PdcaVO) this.getResult(context);

    Row headRow = sh.createRow(row);/*from   w ww.j  av  a  2 s  . c om*/
    headRow.setHeight((short) 700);

    // --------------------------------------------------------------------------------------

    XSSFColor bgColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor("#d8d8d8"));
    XSSFColor fnColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor("#000000"));

    XSSFCellStyle cellHeadStyle = wb.createCellStyle();
    cellHeadStyle.setFillForegroundColor(bgColor);
    cellHeadStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

    XSSFFont cellHeadFont = wb.createFont();
    cellHeadFont.setBold(true);
    cellHeadFont.setColor(fnColor);
    cellHeadStyle.setFont(cellHeadFont);
    cellHeadStyle.setBorderBottom(BorderStyle.THIN);
    cellHeadStyle.setBorderTop(BorderStyle.THIN);
    cellHeadStyle.setBorderRight(BorderStyle.THIN);
    cellHeadStyle.setBorderLeft(BorderStyle.THIN);
    cellHeadStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    cellHeadStyle.setAlignment(HorizontalAlignment.CENTER);
    cellHeadStyle.setWrapText(true);

    // --------------------------------------------------------------------------------------

    int cols = 6;
    for (int i = 0; i < cols; i++) {
        sh.setColumnWidth(i, 6000);
        Cell headCell1 = headRow.createCell(i);
        headCell1.setCellValue(pdca.getTitle());
        headCell1.setCellStyle(cellHeadStyle);
    }
    sh.addMergedRegion(new CellRangeAddress(row, row, 0, cols - 1));

    // --------------------------------------------------------------------------------------

    XSSFColor bgLabelColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor("#F2F2F2"));

    XSSFCellStyle cellLabelStyle = wb.createCellStyle();
    cellLabelStyle.setFillForegroundColor(bgLabelColor);
    cellLabelStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

    XSSFFont cellLabelFont = wb.createFont();
    cellLabelFont.setBold(true);
    cellLabelFont.setColor(fnColor);
    cellLabelStyle.setFont(cellLabelFont);
    cellLabelStyle.setBorderBottom(BorderStyle.THIN);
    cellLabelStyle.setBorderTop(BorderStyle.THIN);
    cellLabelStyle.setBorderRight(BorderStyle.THIN);
    cellLabelStyle.setBorderLeft(BorderStyle.THIN);
    cellLabelStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    cellLabelStyle.setAlignment(HorizontalAlignment.LEFT);
    cellLabelStyle.setWrapText(true);

    // --------------------------------------------------------------------------------------

    XSSFColor bgNormalColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor("#ffffff"));

    XSSFCellStyle cellNormalStyle = wb.createCellStyle();
    cellNormalStyle.setFillForegroundColor(bgNormalColor);
    cellNormalStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

    XSSFFont cellNormalFont = wb.createFont();
    cellNormalFont.setBold(false);
    cellNormalFont.setColor(fnColor);
    cellNormalStyle.setFont(cellNormalFont);
    cellNormalStyle.setBorderBottom(BorderStyle.THIN);
    cellNormalStyle.setBorderTop(BorderStyle.THIN);
    cellNormalStyle.setBorderRight(BorderStyle.THIN);
    cellNormalStyle.setBorderLeft(BorderStyle.THIN);
    cellNormalStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    cellNormalStyle.setAlignment(HorizontalAlignment.LEFT);
    cellNormalStyle.setWrapText(true);

    // --------------------------------------------------------------------------------------

    row++;

    Row labelRow = sh.createRow(row);
    Cell labelCell_0_1 = labelRow.createCell(0);
    labelCell_0_1.setCellValue("Responsibility");
    labelCell_0_1.setCellStyle(cellLabelStyle);

    Cell labelCell_0_2 = labelRow.createCell(1);
    labelCell_0_2.setCellValue(pdca.getResponsibilityAppendNames());
    labelCell_0_2.setCellStyle(cellNormalStyle);

    Cell labelCell_0_3 = labelRow.createCell(2);
    labelCell_0_3.setCellValue(pdca.getResponsibilityAppendNames());
    labelCell_0_3.setCellStyle(cellNormalStyle);

    sh.addMergedRegion(new CellRangeAddress(row, row, 1, 2));

    Cell labelCell_0_4 = labelRow.createCell(3);
    labelCell_0_4.setCellValue("Date range");
    labelCell_0_4.setCellStyle(cellLabelStyle);

    Cell labelCell_0_5 = labelRow.createCell(4);
    labelCell_0_5.setCellValue(pdca.getStartDateDisplayValue() + " ~ " + pdca.getEndDateDisplayValue());
    labelCell_0_5.setCellStyle(cellNormalStyle);

    Cell labelCell_0_6 = labelRow.createCell(5);
    labelCell_0_6.setCellValue(pdca.getStartDateDisplayValue() + " ~ " + pdca.getEndDateDisplayValue());
    labelCell_0_6.setCellStyle(cellNormalStyle);

    sh.addMergedRegion(new CellRangeAddress(row, row, 4, 5));

    // --------------------------------------------------------------------------------------

    row++;

    labelRow = sh.createRow(row);
    Cell labelCell_1_1 = labelRow.createCell(0);
    labelCell_1_1.setCellValue("Confirm");
    labelCell_1_1.setCellStyle(cellLabelStyle);

    Cell labelCell_1_2 = labelRow.createCell(1);
    labelCell_1_2.setCellValue(pdca.getConfirmEmployeeName());
    labelCell_1_2.setCellStyle(cellNormalStyle);

    Cell labelCell_1_3 = labelRow.createCell(2);
    labelCell_1_3.setCellValue(pdca.getConfirmEmployeeName());
    labelCell_1_3.setCellStyle(cellNormalStyle);

    sh.addMergedRegion(new CellRangeAddress(row, row, 1, 2));

    Cell labelCell_1_4 = labelRow.createCell(3);
    labelCell_1_4.setCellValue("Confirm date");
    labelCell_1_4.setCellStyle(cellLabelStyle);

    Cell labelCell_1_5 = labelRow.createCell(4);
    labelCell_1_5.setCellValue(pdca.getConfirmDateDisplayValue());
    labelCell_1_5.setCellStyle(cellNormalStyle);

    Cell labelCell_1_6 = labelRow.createCell(5);
    labelCell_1_6.setCellValue(pdca.getConfirmDateDisplayValue());
    labelCell_1_6.setCellStyle(cellNormalStyle);

    sh.addMergedRegion(new CellRangeAddress(row, row, 4, 5));

    // --------------------------------------------------------------------------------------

    row++;

    labelRow = sh.createRow(row);
    Cell labelCell_2_1 = labelRow.createCell(0);
    labelCell_2_1.setCellValue("Organization\nDepartment");
    labelCell_2_1.setCellStyle(cellLabelStyle);

    Cell labelCell_2_2 = labelRow.createCell(1);
    labelCell_2_2.setCellValue(pdca.getOrganizationAppendNames());
    labelCell_2_2.setCellStyle(cellNormalStyle);

    Cell labelCell_2_3 = labelRow.createCell(2);
    labelCell_2_3.setCellValue(pdca.getOrganizationAppendNames());
    labelCell_2_3.setCellStyle(cellNormalStyle);

    Cell labelCell_2_4 = labelRow.createCell(3);
    labelCell_2_4.setCellValue(pdca.getOrganizationAppendNames());
    labelCell_2_4.setCellStyle(cellNormalStyle);

    Cell labelCell_2_5 = labelRow.createCell(4);
    labelCell_2_5.setCellValue(pdca.getOrganizationAppendNames());
    labelCell_2_5.setCellStyle(cellNormalStyle);

    Cell labelCell_2_6 = labelRow.createCell(5);
    labelCell_2_6.setCellValue(pdca.getOrganizationAppendNames());
    labelCell_2_6.setCellStyle(cellNormalStyle);

    sh.addMergedRegion(new CellRangeAddress(row, row, 1, 5));

    // --------------------------------------------------------------------------------------

    row++;

    labelRow = sh.createRow(row);
    Cell labelCell_3_1 = labelRow.createCell(0);
    labelCell_3_1.setCellValue("KPIs");
    labelCell_3_1.setCellStyle(cellLabelStyle);

    Cell labelCell_3_2 = labelRow.createCell(1);
    labelCell_3_2.setCellValue(pdca.getKpisAppendNames());
    labelCell_3_2.setCellStyle(cellNormalStyle);

    Cell labelCell_3_3 = labelRow.createCell(2);
    labelCell_3_3.setCellValue(pdca.getKpisAppendNames());
    labelCell_3_3.setCellStyle(cellNormalStyle);

    Cell labelCell_3_4 = labelRow.createCell(3);
    labelCell_3_4.setCellValue(pdca.getKpisAppendNames());
    labelCell_3_4.setCellStyle(cellNormalStyle);

    Cell labelCell_3_5 = labelRow.createCell(4);
    labelCell_3_5.setCellValue(pdca.getKpisAppendNames());
    labelCell_3_5.setCellStyle(cellNormalStyle);

    Cell labelCell_3_6 = labelRow.createCell(5);
    labelCell_3_6.setCellValue(pdca.getKpisAppendNames());
    labelCell_3_6.setCellStyle(cellNormalStyle);

    sh.addMergedRegion(new CellRangeAddress(row, row, 1, 5));

    // --------------------------------------------------------------------------------------

    row++;

    labelRow = sh.createRow(row);
    Cell labelCell_4_1 = labelRow.createCell(0);
    labelCell_4_1.setCellValue("Parent PDCA");
    labelCell_4_1.setCellStyle(cellLabelStyle);

    Cell labelCell_4_2 = labelRow.createCell(1);
    labelCell_4_2.setCellValue(pdca.getParentName());
    labelCell_4_2.setCellStyle(cellNormalStyle);

    Cell labelCell_4_3 = labelRow.createCell(2);
    labelCell_4_3.setCellValue(pdca.getParentName());
    labelCell_4_3.setCellStyle(cellNormalStyle);

    Cell labelCell_4_4 = labelRow.createCell(3);
    labelCell_4_4.setCellValue(pdca.getParentName());
    labelCell_4_4.setCellStyle(cellNormalStyle);

    Cell labelCell_4_5 = labelRow.createCell(4);
    labelCell_4_5.setCellValue(pdca.getParentName());
    labelCell_4_5.setCellStyle(cellNormalStyle);

    Cell labelCell_4_6 = labelRow.createCell(5);
    labelCell_4_6.setCellValue(pdca.getParentName());
    labelCell_4_6.setCellStyle(cellNormalStyle);

    sh.addMergedRegion(new CellRangeAddress(row, row, 1, 5));

    // --------------------------------------------------------------------------------------

    row++;

    labelRow = sh.createRow(row);
    Cell labelCell_6_1 = labelRow.createCell(0);
    labelCell_6_1.setCellValue("TYPE");
    labelCell_6_1.setCellStyle(cellLabelStyle);

    Cell labelCell_6_2 = labelRow.createCell(1);
    labelCell_6_2.setCellValue("Title");
    labelCell_6_2.setCellStyle(cellLabelStyle);

    Cell labelCell_6_3 = labelRow.createCell(2);
    labelCell_6_3.setCellValue("Responsibility");
    labelCell_6_3.setCellStyle(cellLabelStyle);

    Cell labelCell_6_4 = labelRow.createCell(3);
    labelCell_6_4.setCellValue("Date range");
    labelCell_6_4.setCellStyle(cellLabelStyle);

    Cell labelCell_6_5 = labelRow.createCell(4);
    labelCell_6_5.setCellValue("Audit");
    labelCell_6_5.setCellStyle(cellLabelStyle);

    Cell labelCell_6_6 = labelRow.createCell(5);
    labelCell_6_6.setCellValue("Audit date");
    labelCell_6_6.setCellStyle(cellLabelStyle);

    // --------------------------------------------------------------------------------------

    row++;

    int nRow = row;

    row = this.createPdcaItem(wb, sh, row, cellNormalStyle, pdca.getItemPlan(), pdca.getAuditPlan());
    row = this.createPdcaItem(wb, sh, row, cellNormalStyle, pdca.getItemDo(), pdca.getAuditDo());
    row = this.createPdcaItem(wb, sh, row, cellNormalStyle, pdca.getItemCheck(), pdca.getAuditCheck());
    row = this.createPdcaItem(wb, sh, row, cellNormalStyle, pdca.getItemAction(), pdca.getAuditAction());

    nRow = this.mergedRegionForItemsRow(wb, sh, nRow, pdca.getItemPlan());
    nRow = this.mergedRegionForItemsRow(wb, sh, nRow, pdca.getItemDo());
    nRow = this.mergedRegionForItemsRow(wb, sh, nRow, pdca.getItemCheck());
    nRow = this.mergedRegionForItemsRow(wb, sh, nRow, pdca.getItemAction());

    return row;
}

From source file:com.netsteadfast.greenstep.bsc.command.PdcaReportExcelCommand.java

License:Apache License

private int createPdcaItem(XSSFWorkbook wb, XSSFSheet sh, int row, XSSFCellStyle cellNormalStyle,
        List<PdcaItemVO> items, PdcaAuditVO audit) throws Exception {

    XSSFColor fnColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor("#000000"));
    XSSFColor bgLabelColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor("#F2F2F2"));

    XSSFCellStyle cellLabelStyle = wb.createCellStyle();
    cellLabelStyle.setFillForegroundColor(bgLabelColor);
    cellLabelStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

    XSSFFont cellLabelFont = wb.createFont();
    cellLabelFont.setBold(true);//  w w w. j  a  v  a 2 s  . c  o m
    cellLabelFont.setColor(fnColor);
    cellLabelStyle.setFont(cellLabelFont);
    cellLabelStyle.setBorderBottom(BorderStyle.THIN);
    cellLabelStyle.setBorderTop(BorderStyle.THIN);
    cellLabelStyle.setBorderRight(BorderStyle.THIN);
    cellLabelStyle.setBorderLeft(BorderStyle.THIN);
    cellLabelStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    cellLabelStyle.setAlignment(HorizontalAlignment.CENTER);
    cellLabelStyle.setWrapText(true);

    Map<String, String> pdcaTypeMap = PdcaType.getDataMap(false);

    for (PdcaItemVO item : items) {

        Row labelRow = sh.createRow(row);
        Cell labelCell_6_1 = labelRow.createCell(0);
        labelCell_6_1.setCellValue(pdcaTypeMap.get(item.getType()));
        labelCell_6_1.setCellStyle(cellLabelStyle);

        Cell labelCell_6_2 = labelRow.createCell(1);
        labelCell_6_2.setCellValue(item.getTitle()
                + (!StringUtils.isBlank(item.getDescription()) ? "\n\n" + item.getDescription() : ""));
        labelCell_6_2.setCellStyle(cellNormalStyle);

        Cell labelCell_6_3 = labelRow.createCell(2);
        labelCell_6_3.setCellValue(item.getEmployeeAppendNames());
        labelCell_6_3.setCellStyle(cellNormalStyle);

        Cell labelCell_6_4 = labelRow.createCell(3);
        labelCell_6_4.setCellValue(item.getStartDateDisplayValue() + " ~ " + item.getEndDateDisplayValue());
        labelCell_6_4.setCellStyle(cellNormalStyle);

        Cell labelCell_6_5 = labelRow.createCell(4);
        labelCell_6_5.setCellValue((audit != null ? audit.getEmpId() : " "));
        labelCell_6_5.setCellStyle(cellNormalStyle);

        Cell labelCell_6_6 = labelRow.createCell(5);
        labelCell_6_6.setCellValue((audit != null ? audit.getConfirmDateDisplayValue() : " "));
        labelCell_6_6.setCellStyle(cellNormalStyle);

        row++;

    }

    return row;
}

From source file:com.netsteadfast.greenstep.bsc.command.PersonalReportExcelCommand.java

License:Apache License

private int createHead(XSSFWorkbook wb, XSSFSheet sh, int row, VisionVO vision, Context context)
        throws Exception {
    String dateType = (String) context.get("dateType");
    String year = (String) context.get("startYearDate");
    String empId = (String) context.get("empId");
    String account = (String) context.get("account");
    String fullName = "";
    String jobTitle = "";
    String departmentName = "";
    String dateTypeName = "Year";
    if ("1".equals(dateType)) {
        dateTypeName = "In the first half";
    }//from   w w w  .ja v a  2  s  .  c  om
    if ("2".equals(dateType)) {
        dateTypeName = "In the second half";
    }
    EmployeeVO employee = new EmployeeVO();
    employee.setEmpId(empId);
    employee.setAccount(account);
    DefaultResult<EmployeeVO> result = this.employeeService.findByUK(employee);
    if (result.getValue() != null) {
        fullName = result.getValue().getEmpId() + " - " + result.getValue().getFullName();
        jobTitle = result.getValue().getEmpId() + " - " + result.getValue().getFullName();
        List<String> appendIds = this.organizationService
                .findForAppendOrganizationOids(result.getValue().getEmpId());
        List<String> appendNames = this.organizationService.findForAppendNames(appendIds);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; appendNames != null && i < appendNames.size(); i++) {
            sb.append(appendNames.get(i)).append(Constants.ID_DELIMITER);
        }
        departmentName = sb.toString();
    }

    Row headRow = sh.createRow(row);
    headRow.setHeight((short) 700);

    XSSFColor bgColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor("#F2F2F2"));
    XSSFColor fnColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor("#000000"));

    XSSFCellStyle cellHeadStyle = wb.createCellStyle();
    cellHeadStyle.setFillForegroundColor(bgColor);
    cellHeadStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

    XSSFFont cellHeadFont = wb.createFont();
    cellHeadFont.setBold(true);
    cellHeadFont.setColor(fnColor);
    cellHeadStyle.setFont(cellHeadFont);
    cellHeadStyle.setBorderBottom(BorderStyle.THIN);
    cellHeadStyle.setBorderTop(BorderStyle.THIN);
    cellHeadStyle.setBorderRight(BorderStyle.THIN);
    cellHeadStyle.setBorderLeft(BorderStyle.THIN);
    cellHeadStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    cellHeadStyle.setAlignment(HorizontalAlignment.CENTER);
    cellHeadStyle.setWrapText(true);

    int cols = 6;
    for (int i = 0; i < cols; i++) {
        sh.setColumnWidth(i, 6000);
        Cell headCell1 = headRow.createCell(i);
        headCell1.setCellValue("Personal Balance SourceCard");
        headCell1.setCellStyle(cellHeadStyle);
    }
    sh.addMergedRegion(new CellRangeAddress(row, row, 0, cols - 1));

    row++;
    headRow = sh.createRow(row);
    for (int i = 0; i < cols; i++) {
        sh.setColumnWidth(i, 6000);
        Cell headCell1 = headRow.createCell(i);
        headCell1.setCellValue(vision.getTitle());
        headCell1.setCellStyle(cellHeadStyle);
    }
    sh.addMergedRegion(new CellRangeAddress(row, row, 0, cols - 1));

    row++;
    headRow = sh.createRow(row);
    headRow.setHeight((short) 700);

    Cell titleCell1 = headRow.createCell(0);
    titleCell1.setCellValue("Job Title");
    titleCell1.setCellStyle(cellHeadStyle);

    Cell titleCell2 = headRow.createCell(1);
    titleCell2.setCellValue(jobTitle);
    titleCell2.setCellStyle(cellHeadStyle);

    Cell titleCell3 = headRow.createCell(2);
    titleCell3.setCellValue("Department");
    titleCell3.setCellStyle(cellHeadStyle);

    Cell titleCell4 = headRow.createCell(3);
    titleCell4.setCellValue(departmentName);
    titleCell4.setCellStyle(cellHeadStyle);

    Cell titleCell5 = headRow.createCell(4);
    titleCell5.setCellValue("name: " + fullName);
    titleCell5.setCellStyle(cellHeadStyle);

    Cell titleCell6 = headRow.createCell(5);
    titleCell6.setCellValue("Annual assessment: " + year);
    titleCell6.setCellStyle(cellHeadStyle);

    row++;
    headRow = sh.createRow(row);

    titleCell1 = headRow.createCell(0);
    titleCell1.setCellValue(BscReportPropertyUtils.getObjectiveTitle());
    titleCell1.setCellStyle(cellHeadStyle);

    titleCell2 = headRow.createCell(1);
    titleCell2.setCellValue(BscReportPropertyUtils.getKpiTitle());
    titleCell2.setCellStyle(cellHeadStyle);

    titleCell3 = headRow.createCell(2);
    titleCell3.setCellValue("Maximum\nTarget\nMinimum");
    titleCell3.setCellStyle(cellHeadStyle);

    titleCell4 = headRow.createCell(3);
    titleCell4.setCellValue("Weight");
    titleCell4.setCellStyle(cellHeadStyle);

    titleCell5 = headRow.createCell(4);
    titleCell5.setCellValue("Formula");
    titleCell5.setCellStyle(cellHeadStyle);

    titleCell6 = headRow.createCell(5);
    titleCell6.setCellValue("Score");
    titleCell6.setCellStyle(cellHeadStyle);

    row++;
    headRow = sh.createRow(row);
    headRow.setHeight((short) 1000);

    titleCell1 = headRow.createCell(0);
    titleCell1.setCellValue("Objective of Strategy");
    titleCell1.setCellStyle(cellHeadStyle);

    titleCell2 = headRow.createCell(1);
    titleCell2.setCellValue("KPI");
    titleCell2.setCellStyle(cellHeadStyle);

    titleCell3 = headRow.createCell(2);
    titleCell3.setCellValue("Target");
    titleCell3.setCellStyle(cellHeadStyle);

    titleCell4 = headRow.createCell(3);
    titleCell4.setCellValue("Weight");
    titleCell4.setCellStyle(cellHeadStyle);

    titleCell5 = headRow.createCell(4);
    titleCell5.setCellValue("Formula");
    titleCell5.setCellStyle(cellHeadStyle);

    XSSFCellStyle titleStyle = wb.createCellStyle();
    titleStyle.setFillForegroundColor(bgColor);
    titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    titleStyle.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#F5F4F4")));
    titleStyle.setFont(cellHeadFont);
    titleStyle.setBorderBottom(BorderStyle.THIN);
    titleStyle.setBorderTop(BorderStyle.THIN);
    titleStyle.setBorderRight(BorderStyle.THIN);
    titleStyle.setBorderLeft(BorderStyle.THIN);
    titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    titleStyle.setAlignment(HorizontalAlignment.CENTER);
    titleStyle.setWrapText(true);

    titleCell6 = headRow.createCell(5);
    titleCell6.setCellValue(dateTypeName);
    titleCell6.setCellStyle(titleStyle);

    for (int i = 0; i < 5; i++) {
        sh.addMergedRegion(new CellRangeAddress(row - 1, row, i, i));
    }

    return 5;
}

From source file:com.netsteadfast.greenstep.bsc.command.PersonalReportExcelCommand.java

License:Apache License

private int createMainBody(XSSFWorkbook wb, XSSFSheet sh, int row, VisionVO vision, Context context)
        throws Exception {
    int mrRow = row;

    XSSFCellStyle cellStyle = wb.createCellStyle();
    cellStyle.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#ffffff")));
    cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

    XSSFFont cellFont = wb.createFont();
    cellFont.setBold(false);/*from ww  w .jav  a 2 s .  c om*/
    cellFont.setColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#000000")));
    cellStyle.setFont(cellFont);
    cellStyle.setWrapText(true);
    cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    cellStyle.setBorderBottom(BorderStyle.THIN);
    cellStyle.setBorderTop(BorderStyle.THIN);
    cellStyle.setBorderRight(BorderStyle.THIN);
    cellStyle.setBorderLeft(BorderStyle.THIN);
    cellStyle.setWrapText(true);

    for (PerspectiveVO perspective : vision.getPerspectives()) {
        for (ObjectiveVO objective : perspective.getObjectives()) {
            for (KpiVO kpi : objective.getKpis()) {
                int kCol = 0;
                Row contentRow = sh.createRow(row++);
                contentRow.setHeight((short) 1000);

                Cell contentCell1 = contentRow.createCell(kCol++);
                contentCell1.setCellValue(objective.getName());
                contentCell1.setCellStyle(cellStyle);

                Cell contentCell2 = contentRow.createCell(kCol++);
                contentCell2.setCellValue(kpi.getName());
                contentCell2.setCellStyle(cellStyle);

                Cell contentCell3 = contentRow.createCell(kCol++);
                contentCell3.setCellValue("max: " + kpi.getMax() + "\n" + "target: " + kpi.getTarget() + "\n"
                        + "min: " + kpi.getMin() + "\n" + "unit: " + kpi.getUnit());
                contentCell3.setCellStyle(cellStyle);

                Cell contentCell4 = contentRow.createCell(kCol++);
                contentCell4.setCellValue(kpi.getWeight() + "%");
                contentCell4.setCellStyle(cellStyle);

                Cell contentCell5 = contentRow.createCell(kCol++);
                contentCell5.setCellValue(kpi.getFormula().getName());
                contentCell5.setCellStyle(cellStyle);

                DateRangeScoreVO dateRangeScore = kpi.getDateRangeScores().get(0); // ?

                XSSFCellStyle cellStyleScore = wb.createCellStyle();
                cellStyleScore.setFillForegroundColor(
                        new XSSFColor(SimpleUtils.getColorRGB4POIColor(dateRangeScore.getBgColor())));
                cellStyleScore.setFillPattern(FillPatternType.SOLID_FOREGROUND);

                XSSFFont cellScoreFont = wb.createFont();
                cellScoreFont.setBold(false);
                cellScoreFont.setColor(
                        new XSSFColor(SimpleUtils.getColorRGB4POIColor(dateRangeScore.getFontColor())));
                cellStyleScore.setFont(cellScoreFont);
                cellStyleScore.setWrapText(true);
                cellStyleScore.setVerticalAlignment(VerticalAlignment.CENTER);
                cellStyleScore.setBorderBottom(BorderStyle.THIN);
                cellStyleScore.setBorderTop(BorderStyle.THIN);
                cellStyleScore.setBorderRight(BorderStyle.THIN);
                cellStyleScore.setBorderLeft(BorderStyle.THIN);

                Cell contentCell6 = contentRow.createCell(kCol++);
                contentCell6.setCellValue(BscReportSupportUtils.parse2(dateRangeScore.getScore()));
                contentCell6.setCellStyle(cellStyleScore);

            }
        }
    }

    for (PerspectiveVO perspective : vision.getPerspectives()) {
        for (ObjectiveVO objective : perspective.getObjectives()) {
            int rowspan = objective.getRow();
            if (objective.getRow() > 1) {
                // 2016-12-13 old work with POI 3.12
                //sh.addMergedRegion(new CellRangeAddress(mrRow, mrRow+rowspan-1, 0, 0));

                // 2016-12-13 new work with POI 3.15
                int mrRow1 = mrRow + rowspan - 1;
                if (mrRow1 > mrRow) {
                    sh.addMergedRegion(new CellRangeAddress(mrRow, mrRow1, 0, 0));
                }

            }
            mrRow += rowspan;
        }
    }

    return row;
}

From source file:com.netsteadfast.greenstep.bsc.command.PersonalReportExcelCommand.java

License:Apache License

private void createFoot(XSSFWorkbook wb, XSSFSheet sh, int row, VisionVO vision, Context context)
        throws Exception {

    Row footRow = sh.createRow(row);/* w  w  w . j  av a 2  s  .  c o m*/
    Row footRowB = sh.createRow(row + 1);
    XSSFCellStyle cellStyle = wb.createCellStyle();

    cellStyle.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#FFFFFF")));
    cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    cellStyle.setBorderBottom(BorderStyle.THIN);
    cellStyle.setBorderTop(BorderStyle.THIN);
    cellStyle.setBorderRight(BorderStyle.THIN);
    cellStyle.setBorderLeft(BorderStyle.THIN);
    XSSFFont cellFont = wb.createFont();
    cellFont.setBold(true);
    cellStyle.setFont(cellFont);
    cellStyle.setWrapText(true);

    Cell footCell1 = footRow.createCell(0);
    footCell1.setCellValue("assess:");
    footCell1.setCellStyle(cellStyle);
    Cell footCell1B = footRowB.createCell(0);
    footCell1B.setCellValue("assess:");
    footCell1B.setCellStyle(cellStyle);
    sh.addMergedRegion(new CellRangeAddress(row, row + 1, 0, 0));

    Cell footCell2 = footRow.createCell(1);
    footCell2.setCellValue(BscReportPropertyUtils.getPersonalReportClassLevel());
    footCell2.setCellStyle(cellStyle);
    Cell footCell3 = footRow.createCell(2);
    footCell3.setCellValue(BscReportPropertyUtils.getPersonalReportClassLevel());
    footCell3.setCellStyle(cellStyle);
    Cell footCell4 = footRow.createCell(3);
    footCell4.setCellValue(BscReportPropertyUtils.getPersonalReportClassLevel());
    footCell4.setCellStyle(cellStyle);
    Cell footCell2B = footRowB.createCell(1);
    footCell2B.setCellValue(BscReportPropertyUtils.getPersonalReportClassLevel());
    footCell2B.setCellStyle(cellStyle);
    Cell footCell3B = footRowB.createCell(2);
    footCell3B.setCellValue(BscReportPropertyUtils.getPersonalReportClassLevel());
    footCell3B.setCellStyle(cellStyle);
    Cell footCell4B = footRowB.createCell(3);
    footCell4B.setCellValue(BscReportPropertyUtils.getPersonalReportClassLevel());
    footCell4B.setCellStyle(cellStyle);
    sh.addMergedRegion(new CellRangeAddress(row, row + 1, 1, 3));

    Cell footCell5 = footRow.createCell(4);
    footCell5.setCellValue("Total");
    footCell5.setCellStyle(cellStyle);

    float total = 0.0f;
    if (context.get("total") != null && context.get("total") instanceof Float) {
        total = (Float) context.get("total");
    }

    Cell footCell6 = footRow.createCell(5);
    footCell6.setCellValue(BscReportSupportUtils.parse2(total));
    footCell6.setCellStyle(cellStyle);

    Cell footCell5b = footRowB.createCell(4);
    footCell5b.setCellValue("Class");
    footCell5b.setCellStyle(cellStyle);

    Cell footCell6b = footRowB.createCell(5);
    footCell6b.setCellValue("");
    footCell6b.setCellStyle(cellStyle);

}

From source file:com.respam.comniq.models.POIexcelExporter.java

License:Open Source License

public void createFile() throws IOException {
    String path = System.getProperty("user.home") + File.separator + "comniq" + File.separator + "output";
    File file = new File(path + File.separator + "POImovieInfo.xlsx");

    // Blank Workbook
    XSSFWorkbook workbook = new XSSFWorkbook();
    XSSFSheet sheet = workbook.createSheet("Movies");

    // Data for Labels
    Map<String, Object[]> label = new TreeMap<>();
    label.put("1", new Object[] { "Poster", "Title", "Release Date", "Metascore", "IMDB Rating", "Plot",
            "IMDB URL", "Genre", "Director", "Actors", "Rating", "Runtime" });

    // Iterate over label and write to sheet
    Set<String> keyset = label.keySet();

    // Setting Style for the Label Row
    Font font = workbook.createFont();
    font.setFontHeight((short) 240);
    font.setFontName("Courier New");
    font.setBold(true);//  w w w.j av  a 2s.  c  o m
    XSSFCellStyle labelStyle = workbook.createCellStyle();
    labelStyle.setWrapText(true);
    labelStyle.setFont(font);

    // Setting column widths
    sheet.setColumnWidth(0, 4000);
    sheet.setColumnWidth(1, 8500);
    sheet.setColumnWidth(2, 4000);
    sheet.setColumnWidth(3, 4000);
    sheet.setColumnWidth(4, 3500);
    sheet.setColumnWidth(5, 9500);
    sheet.setColumnWidth(6, 5000);
    sheet.setColumnWidth(7, 4000);
    sheet.setColumnWidth(8, 3500);
    sheet.setColumnWidth(9, 4000);
    sheet.setColumnWidth(10, 3000);
    sheet.setColumnWidth(11, 4000);

    // Freezing the first row
    sheet.createFreezePane(0, 1);

    // Filling each cell with Label data
    for (String key : keyset) {
        Row row = sheet.createRow(0);
        Object[] objArr = label.get(key);
        int cellnum = 0;
        for (Object obj : objArr) {
            Cell cell = row.createCell(cellnum++);
            cell.setCellStyle(labelStyle);
            cell.setCellValue((String) obj);
        }
    }

    // Writing the excel file
    try {
        FileOutputStream out = new FileOutputStream(file);
        workbook.write(out);
        out.close();
        System.out.println("Excel File Created");
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.respam.comniq.models.POIexcelExporter.java

License:Open Source License

public void excelWriter(JSONObject parsedObj, int rownum) throws IOException {
    String path = System.getProperty("user.home") + File.separator + "comniq" + File.separator + "output";
    File file = new File(path + File.separator + "POImovieInfo.xlsx");

    String thumbnailPath = System.getProperty("user.home") + File.separator + "comniq" + File.separator
            + "output" + File.separator + "thumbnails";
    File posterFile = new File(thumbnailPath + File.separator + parsedObj.get("Title") + ".jpg");

    if (!file.exists()) {
        createFile();//ww w.j a va2 s  .  c  om
    }

    if (file.exists() && checked.equals(false)) {
        findLastRow();
    }

    try {
        FileInputStream fis = new FileInputStream(file);
        XSSFWorkbook workbook = new XSSFWorkbook(fis);

        XSSFSheet sheet = workbook.getSheet("Movies");

        Map<String, Object[]> label = new TreeMap<>();
        label.put("1",
                new Object[] { "", parsedObj.get("Title"), parsedObj.get("Released"),
                        parsedObj.get("Metascore"), parsedObj.get("imdbRating"), parsedObj.get("Plot"),
                        parsedObj.get("imdbID"), parsedObj.get("Genre"), parsedObj.get("Director"),
                        parsedObj.get("Actors"), parsedObj.get("Rated"), parsedObj.get("Runtime") });

        Set<String> keyset = label.keySet();

        // Setting Style for the Label Row

        XSSFCellStyle contentStyle = workbook.createCellStyle();
        contentStyle.setWrapText(true);
        contentStyle.setVerticalAlignment(VerticalAlignment.TOP);

        rownum = rownum + lastRow;

        if (posterFile.exists()) {
            InputStream imageStream = new FileInputStream(
                    thumbnailPath + File.separator + parsedObj.get("Title") + ".jpg");
            byte[] imageBytes = IOUtils.toByteArray(imageStream);
            pictureureIdx = workbook.addPicture(imageBytes, Workbook.PICTURE_TYPE_PNG);
            imageStream.close();

            CreationHelper helper = workbook.getCreationHelper();
            drawing = sheet.createDrawingPatriarch();
            anchor = helper.createClientAnchor();

        }

        for (String key : keyset) {

            Row row = sheet.createRow(rownum++);
            row.setHeight((short) 2000);
            Object[] objArr = label.get(key);
            int cellnum = 0;
            for (Object obj : objArr) {
                Cell cell = row.createCell(cellnum++);
                cell.setCellStyle(contentStyle);
                cell.setCellValue((String) obj);
            }
            if (posterFile.exists()) {
                anchor.setCol1(0);
                anchor.setRow1(rownum - 1);
                anchor.setCol2(0);
                anchor.setRow2(rownum - 1);
                Picture pict = drawing.createPicture(anchor, pictureureIdx);
                pict.resize(1, 1);
            }
        }
        FileOutputStream out = new FileOutputStream(file);
        workbook.write(out);
        out.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.sec.ose.osi.report.standard.CoverSheetTemplate.java

License:Open Source License

protected XSSFCellStyle getCellStyle(int border, Font font) {
    XSSFCellStyle style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setWrapText(true); // new line

    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());

    if ((border & BORDER_BOTTOM) > 0)
        style.setBorderBottom(CellStyle.BORDER_DOUBLE);
    else/*www .  j a  v  a  2s .co  m*/
        style.setBorderBottom(CellStyle.BORDER_THIN);

    if ((border & BORDER_LEFT) > 0)
        style.setBorderLeft(CellStyle.BORDER_DOUBLE);
    else
        style.setBorderLeft(CellStyle.BORDER_THIN);

    if ((border & BORDER_RIGHT) > 0)
        style.setBorderRight(CellStyle.BORDER_DOUBLE);
    else
        style.setBorderRight(CellStyle.BORDER_THIN);

    if ((border & BORDER_TOP) > 0)
        style.setBorderTop(CellStyle.BORDER_DOUBLE);
    else
        style.setBorderTop(CellStyle.BORDER_THIN);

    if (font != null)
        style.setFont(font);

    return style;
}