Search in sources :

Example 36 with XSSFCellStyle

use of org.apache.poi.xssf.usermodel.XSSFCellStyle in project bamboobsc by billchen198318.

the class PdcaReportExcelCommand method createPdca.

private int createPdca(XSSFWorkbook wb, XSSFSheet sh, int row, Context context) throws Exception {
    PdcaVO pdca = (PdcaVO) this.getResult(context);
    Row headRow = sh.createRow(row);
    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;
}
Also used : XSSFColor(org.apache.poi.xssf.usermodel.XSSFColor) XSSFCellStyle(org.apache.poi.xssf.usermodel.XSSFCellStyle) XSSFFont(org.apache.poi.xssf.usermodel.XSSFFont) PdcaVO(com.netsteadfast.greenstep.vo.PdcaVO) Row(org.apache.poi.ss.usermodel.Row) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) Cell(org.apache.poi.ss.usermodel.Cell)

Example 37 with XSSFCellStyle

use of org.apache.poi.xssf.usermodel.XSSFCellStyle in project Gargoyle by callakrsos.

the class ExcelUtil method applyColor.

private static void applyColor(Workbook createNewWorkBookXlsx, ExcelDataDVO dvo, Cell createCell) {
    Color backgroundColor = dvo.getBackgroundColor();
    if (backgroundColor != null) {
        XSSFCellStyle style = (XSSFCellStyle) createNewWorkBookXlsx.createCellStyle();
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        style.setFillForegroundColor(new XSSFColor(backgroundColor));
        createCell.setCellStyle(style);
    }
}
Also used : XSSFColor(org.apache.poi.xssf.usermodel.XSSFColor) XSSFCellStyle(org.apache.poi.xssf.usermodel.XSSFCellStyle) Color(java.awt.Color) XSSFColor(org.apache.poi.xssf.usermodel.XSSFColor)

Example 38 with XSSFCellStyle

use of org.apache.poi.xssf.usermodel.XSSFCellStyle in project Gargoyle by callakrsos.

the class ExcelUtil method applyColor.

private static void applyColor(Workbook createNewWorkBookXlsx, ExcelColDVO dvo, Cell createCell) {
    Color backgroundColor = dvo.getBackgroundColor();
    if (backgroundColor != null) {
        XSSFCellStyle style = (XSSFCellStyle) createNewWorkBookXlsx.createCellStyle();
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        style.setFillForegroundColor(new XSSFColor(backgroundColor));
        createCell.setCellStyle(style);
    }
}
Also used : XSSFColor(org.apache.poi.xssf.usermodel.XSSFColor) XSSFCellStyle(org.apache.poi.xssf.usermodel.XSSFCellStyle) Color(java.awt.Color) XSSFColor(org.apache.poi.xssf.usermodel.XSSFColor)

Aggregations

XSSFCellStyle (org.apache.poi.xssf.usermodel.XSSFCellStyle)38 XSSFFont (org.apache.poi.xssf.usermodel.XSSFFont)22 XSSFColor (org.apache.poi.xssf.usermodel.XSSFColor)20 Cell (org.apache.poi.ss.usermodel.Cell)16 Row (org.apache.poi.ss.usermodel.Row)16 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)13 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)12 File (java.io.File)8 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)8 HashMap (java.util.HashMap)7 XlsxWriterHelper (com.cubrid.common.ui.cubrid.table.control.XlsxWriterHelper)6 FileOutputStream (java.io.FileOutputStream)6 List (java.util.List)6 XSSFCell (org.apache.poi.xssf.usermodel.XSSFCell)6 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)5 ArrayList (java.util.ArrayList)5 DateRangeScoreVO (com.netsteadfast.greenstep.vo.DateRangeScoreVO)4 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)4 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)4 OutputStreamWriter (java.io.OutputStreamWriter)4