List of usage examples for org.apache.poi.xssf.usermodel XSSFCellStyle setAlignment
@Override public void setAlignment(HorizontalAlignment align)
From source file:com.hauldata.dbpa.file.book.XlsxTargetSheet.java
License:Apache License
/** * Translate styling to workbook CellStyle. * * @param stylesUsed tracks the styles that have been used in the workbook; it will be updated * @param fontsUsed tracks the fonts that have been used in the workbook; it may be updated * @param colorsUsed tracks the colors that have been used in the workbook; it may be updated *//*from ww w .ja v a2 s. c o m*/ public CellStyle getCellStyle(SXSSFWorkbook book, Map<StylesWithFormatting, XSSFCellStyle> stylesUsed, Map<FontStyles, XSSFFont> fontsUsed, Map<Integer, XSSFColor> colorsUsed) { XSSFCellStyle cellStyle = stylesUsed.get(this); if (cellStyle != null) { return cellStyle; } cellStyle = (XSSFCellStyle) book.createCellStyle(); cellStyle.cloneStyleFrom(book.getCellStyleAt(formatIndex)); if (styles.bottomBorder.style != null) { cellStyle.setBorderBottom(resolveBorderStyle(styles.bottomBorder)); } if (styles.leftBorder.style != null) { cellStyle.setBorderLeft(resolveBorderStyle(styles.leftBorder)); } if (styles.rightBorder.style != null) { cellStyle.setBorderRight(resolveBorderStyle(styles.rightBorder)); } if (styles.topBorder.style != null) { cellStyle.setBorderTop(resolveBorderStyle(styles.topBorder)); } if (styles.bottomBorder.color != null) { cellStyle.setBottomBorderColor(getColor(styles.bottomBorder.color, book, colorsUsed)); } if (styles.leftBorder.color != null) { cellStyle.setLeftBorderColor(getColor(styles.leftBorder.color, book, colorsUsed)); } if (styles.rightBorder.color != null) { cellStyle.setRightBorderColor(getColor(styles.rightBorder.color, book, colorsUsed)); } if (styles.topBorder.color != null) { cellStyle.setTopBorderColor(getColor(styles.topBorder.color, book, colorsUsed)); } if (styles.backgroundColor != null) { cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); cellStyle.setFillForegroundColor(getColor(styles.backgroundColor, book, colorsUsed)); } if (styles.textAlign != null) { cellStyle.setAlignment(styles.textAlign); } if (!styles.font.areDefault()) { cellStyle.setFont(getFont(styles.font, book, fontsUsed, colorsUsed)); } stylesUsed.put(this, cellStyle); return cellStyle; }
From source file:com.l3.info.magenda.emplois_du_temps.Semaine.java
void writeInSheet(Workbook workbook, int week_of_year) { XSSFWorkbook xssfWorkbook = workbook.getWorkbook(); Sheet sheet = xssfWorkbook.createSheet("Sem. " + week_of_year); Row row = sheet.createRow((short) 0); row.setHeight(Workbook.PixelsToTwips(64)); Cell cell = row.createCell((short) 0); // first row (0-based) - last row (0-based) - first column (0-based) -last column (0-based) sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, (20 - 7) * 2 + 2)); // Cree une nouvelle police Font font = xssfWorkbook.createFont(); font.setFontHeightInPoints((short) 18); font.setFontName("Arial"); // Fonts are set into a style so create a new one to use. XSSFCellStyle style = xssfWorkbook.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); style.setFont(font);//from www .j ava 2s . co m // Create a cell and put a value in it. cell.setCellValue("Semaine " + this.num_semaine); cell.setCellStyle(style); sheet.setDefaultRowHeight((short) 500); int x = 0, y = 2; for (Jour day : days_of_week) { day.writeInSheet(workbook, sheet, x, y); y += 2 + day.getNbrLigne(); } }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportExcelCommand.java
License:Apache License
private int createHead(XSSFWorkbook wb, XSSFSheet sh, int row, VisionVO vision) throws Exception { Row headRow = sh.createRow(row);//from ww w.j a v a 2 s . c o m headRow.setHeight((short) 700); int cell = 0; XSSFColor bgColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor(vision.getBgColor())); XSSFColor fnColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor(vision.getFontColor())); 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 = 12; for (int i = 0; i < cols; i++) { sh.setColumnWidth(i, 4000); Cell headCell1 = headRow.createCell(cell++); headCell1.setCellValue( vision.getTitle() + "\nscore: " + BscReportSupportUtils.parse2(vision.getScore())); headCell1.setCellStyle(cellHeadStyle); } sh.addMergedRegion(new CellRangeAddress(row, row, 0, cols - 1)); // ------------------------------------------------------------------------ bgColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor(BscReportPropertyUtils.getBackgroundColor())); fnColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor(BscReportPropertyUtils.getFontColor())); cellHeadStyle = wb.createCellStyle(); cellHeadStyle.setFillForegroundColor(bgColor); cellHeadStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); 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); row++; headRow = sh.createRow(row); cell = 0; int titleCols = 4; for (int i = 0; i < titleCols; i++) { Cell headCell1 = headRow.createCell(cell++); headCell1.setCellValue(BscReportPropertyUtils.getPerspectiveTitle()); headCell1.setCellStyle(cellHeadStyle); } for (int i = 0; i < titleCols; i++) { Cell headCell1 = headRow.createCell(cell++); headCell1.setCellValue(BscReportPropertyUtils.getObjectiveTitle()); headCell1.setCellStyle(cellHeadStyle); } for (int i = 0; i < titleCols; i++) { Cell headCell1 = headRow.createCell(cell++); headCell1.setCellValue(BscReportPropertyUtils.getKpiTitle()); headCell1.setCellStyle(cellHeadStyle); } sh.addMergedRegion(new CellRangeAddress(row, row, 0, 3)); sh.addMergedRegion(new CellRangeAddress(row, row, 4, 7)); sh.addMergedRegion(new CellRangeAddress(row, row, 8, 11)); // ------------------------------------------------------------------------ return 2; }
From source file:com.netsteadfast.greenstep.bsc.command.KpisDashboardExcelCommand.java
License:Apache License
@SuppressWarnings("unchecked") private int putTables(XSSFWorkbook wb, XSSFSheet sh, Context context) throws Exception { XSSFCellStyle cellHeadStyle = wb.createCellStyle(); cellHeadStyle.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#f5f5f5"))); cellHeadStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); cellHeadStyle.setBorderBottom(BorderStyle.THIN); cellHeadStyle.setBorderTop(BorderStyle.THIN); cellHeadStyle.setBorderRight(BorderStyle.THIN); cellHeadStyle.setBorderLeft(BorderStyle.THIN); XSSFFont cellHeadFont = wb.createFont(); cellHeadFont.setBold(true);/*ww w . j a v a2s . c o m*/ cellHeadStyle.setFont(cellHeadFont); sh.setColumnWidth(0, 12000); int left = 0; int row = 0; List<Map<String, Object>> chartDatas = (List<Map<String, Object>>) context.get("chartDatas"); for (Map<String, Object> data : chartDatas) { Row nowRow = sh.createRow(row); Map<String, Object> nodeData = (Map<String, Object>) ((List<Object>) data.get("datas")).get(0); if (row == 0) { Cell cell1 = nowRow.createCell(0); cell1.setCellStyle(cellHeadStyle); cell1.setCellValue("KPI"); Cell cell2 = nowRow.createCell(1); cell2.setCellStyle(cellHeadStyle); cell2.setCellValue("Maximum"); Cell cell3 = nowRow.createCell(2); cell3.setCellStyle(cellHeadStyle); cell3.setCellValue("Target"); Cell cell4 = nowRow.createCell(3); cell4.setCellStyle(cellHeadStyle); cell4.setCellValue("Minimum"); Cell cell5 = nowRow.createCell(4); cell5.setCellStyle(cellHeadStyle); cell5.setCellValue("Score"); List<Map<String, Object>> dateRangeScores = (List<Map<String, Object>>) nodeData .get("dateRangeScores"); for (Map<String, Object> rangeScore : dateRangeScores) { Cell cell = nowRow.createCell(5 + left); cell.setCellStyle(cellHeadStyle); cell.setCellValue(String.valueOf(rangeScore.get("date"))); left++; } row++; } left = 0; nowRow = sh.createRow(row); XSSFColor bgColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor((String) nodeData.get("bgColor"))); XSSFColor fnColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor((String) nodeData.get("fontColor"))); XSSFCellStyle cellStyle = wb.createCellStyle(); cellStyle.setFillForegroundColor(bgColor); cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); XSSFFont cellFont = wb.createFont(); cellFont.setBold(false); cellFont.setColor(fnColor); cellStyle.setFont(cellFont); cellStyle.setWrapText(true); cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); cellStyle.setAlignment(HorizontalAlignment.CENTER); cellStyle.setBorderBottom(BorderStyle.THIN); cellStyle.setBorderTop(BorderStyle.THIN); cellStyle.setBorderRight(BorderStyle.THIN); cellStyle.setBorderLeft(BorderStyle.THIN); Cell cell1 = nowRow.createCell(0); cell1.setCellValue(String.valueOf(nodeData.get("name"))); Cell cell2 = nowRow.createCell(1); cell2.setCellValue(String.valueOf(nodeData.get("max"))); Cell cell3 = nowRow.createCell(2); cell3.setCellValue(String.valueOf(nodeData.get("target"))); Cell cell4 = nowRow.createCell(3); cell4.setCellValue(String.valueOf(nodeData.get("min"))); Cell cell5 = nowRow.createCell(4); cell5.setCellValue(String.valueOf(nodeData.get("score"))); cell5.setCellStyle(cellStyle); List<Map<String, Object>> dateRangeScores = (List<Map<String, Object>>) nodeData.get("dateRangeScores"); for (Map<String, Object> rangeScore : dateRangeScores) { bgColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor((String) rangeScore.get("bgColor"))); fnColor = new XSSFColor(SimpleUtils.getColorRGB4POIColor((String) rangeScore.get("fontColor"))); cellStyle = wb.createCellStyle(); cellStyle.setFillForegroundColor(bgColor); cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); cellFont = wb.createFont(); cellFont.setBold(false); cellFont.setColor(fnColor); cellStyle.setFont(cellFont); cellStyle.setWrapText(true); cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); cellStyle.setAlignment(HorizontalAlignment.CENTER); cellStyle.setBorderBottom(BorderStyle.THIN); cellStyle.setBorderTop(BorderStyle.THIN); cellStyle.setBorderRight(BorderStyle.THIN); cellStyle.setBorderLeft(BorderStyle.THIN); Cell cell = nowRow.createCell(5 + left); cell.setCellStyle(cellHeadStyle); cell.setCellValue(String.valueOf(rangeScore.get("score"))); cell.setCellStyle(cellStyle); left++; } row++; } return row + 1; }
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"; }// www.j a v a 2s. 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.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 ww w. java2 s . co m*/ 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 ww . java2 s . c om 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"; }// w w w.j a va 2s. 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.pe.nisira.movil.view.action.MultitablaAction.java
public StreamedContent downFormatExcel() throws Exception { InputStream stream = null;/*from w ww.ja va 2 s . c om*/ StreamedContent arch = null; try { String folder = "C:\\SOLUTION\\WEB\\FORMATOS_IMPORTACION"; File ruta = new File(folder); if (!ruta.isDirectory()) { ruta.mkdirs(); } String rutaArchivo = folder + "\\FI_MULTITABLA.xlsx"; File fileXls = new File(rutaArchivo); if (fileXls.exists()) { fileXls.delete(); } fileXls.createNewFile(); XSSFWorkbook libro = new XSSFWorkbook(); FileOutputStream file = new FileOutputStream(fileXls); XSSFSheet hoja = libro.createSheet("IMPORTAR_MULTITABLA"); CreationHelper factory = libro.getCreationHelper(); hoja = libro.getSheetAt(0); XSSFCellStyle style = libro.createCellStyle(); Font font = libro.createFont(); Font font1 = libro.createFont(); Drawing drawing = hoja.createDrawingPatriarch(); ClientAnchor anchor1 = factory.createClientAnchor(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontHeightInPoints((short) 8); font1.setFontHeightInPoints((short) 8); font1.setFontName("Arial"); font.setFontName("Arial"); style.setFillForegroundColor(new XSSFColor(new java.awt.Color(247, 150, 70))); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setAlignment(CellStyle.VERTICAL_CENTER); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); for (int f = 0; f < 1; f++) { XSSFRow fila = hoja.createRow(f); for (int c = 0; c < 4; c++) { XSSFCell celda = fila.createCell(c); celda.setCellStyle(style); anchor1.setCol1(celda.getColumnIndex()); anchor1.setCol2(celda.getColumnIndex() + 4); anchor1.setRow1(fila.getRowNum()); anchor1.setRow2(fila.getRowNum() + 3); Comment comment = drawing.createCellComment(anchor1); if (f == 0 && c == 0) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Indicar si es es Padre (Usar SI o NO)."); str.applyFont(font1); str.applyFont(0, 29, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("Es Padre"); celda.setCellComment(comment); } else if (f == 0 && c == 1) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Opcional \n - Escribir la Abreviatura del campo del cual depende este."); str.applyFont(font1); str.applyFont(0, 29, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("Abreviatura Padre"); celda.setCellComment(comment); } else if (f == 0 && c == 2) { RichTextString str = factory .createRichTextString("ADM:\nCampo Obligatorio \n - Descripcion de la multitabla"); str.applyFont(font1); str.applyFont(0, 29, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("DESCRIPCION"); celda.setCellComment(comment); } else if (f == 0 && c == 3) { RichTextString str = factory .createRichTextString("ADM:\nCampo Obligatorio \n - Abreviatura de la multitabla."); str.applyFont(font1); str.applyFont(0, 29, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("ABREVIATURA"); celda.setCellComment(comment); } } } hoja.autoSizeColumn((short) 0); hoja.autoSizeColumn((short) 1); hoja.autoSizeColumn((short) 2); libro.write(file); file.close(); stream = new FileInputStream(new File(rutaArchivo)); arch = new DefaultStreamedContent(stream, "application/xlsx", "FI_MULTITABLA.xlsx"); } catch (FileNotFoundException ex) { System.out.println("Error al Descargar : " + ex.getMessage()); } return arch; }
From source file:com.pe.nisira.movil.view.action.RegistroPaleta.java
public StreamedContent downFormatExcel() throws Exception { InputStream stream = null;/*from w ww .j a va2s .co m*/ StreamedContent arch = null; try { String folder = "C:\\SOLUTION\\WEB\\FORMATOS_IMPORTACION"; File ruta = new File(folder); if (!ruta.isDirectory()) { ruta.mkdirs(); } String rutaArchivo = folder + "\\FI_REGISTROPALE.xlsx"; File fileXls = new File(rutaArchivo); if (fileXls.exists()) { fileXls.delete(); } fileXls.createNewFile(); XSSFWorkbook libro = new XSSFWorkbook(); FileOutputStream file2 = new FileOutputStream(fileXls); XSSFSheet hoja = libro.createSheet("IMPORTAR_PALETA"); CreationHelper factory = libro.getCreationHelper(); hoja = libro.getSheetAt(0); XSSFCellStyle style = libro.createCellStyle(); Font font = libro.createFont(); Font font1 = libro.createFont(); Drawing drawing = hoja.createDrawingPatriarch(); ClientAnchor anchor1 = factory.createClientAnchor(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setFontHeightInPoints((short) 8); font1.setFontHeightInPoints((short) 8); font1.setFontName("Arial"); font.setFontName("Arial"); style.setFillForegroundColor(new XSSFColor(new java.awt.Color(247, 150, 70))); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setAlignment(CellStyle.VERTICAL_CENTER); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font); XSSFSheet hoja2 = libro.createSheet("IMPORTAR_DET_PALETA"); CreationHelper factory2 = libro.getCreationHelper(); hoja2 = libro.getSheetAt(1); XSSFCellStyle style2 = libro.createCellStyle(); Font font2 = libro.createFont(); Font font12 = libro.createFont(); Drawing drawing2 = hoja2.createDrawingPatriarch(); ClientAnchor anchor12 = factory2.createClientAnchor(); font2.setBoldweight(Font.BOLDWEIGHT_BOLD); font2.setFontHeightInPoints((short) 8); font12.setFontHeightInPoints((short) 8); font12.setFontName("Arial"); font2.setFontName("Arial"); style2.setFillForegroundColor(new XSSFColor(new java.awt.Color(247, 150, 70))); style2.setFillPattern(CellStyle.SOLID_FOREGROUND); style2.setAlignment(CellStyle.VERTICAL_CENTER); style2.setAlignment(CellStyle.ALIGN_CENTER); style2.setFont(font); for (int f = 0; f < 1; f++) { XSSFRow fila = hoja.createRow(f); for (int c = 0; c < 29; c++) { XSSFCell celda = fila.createCell(c); celda.setCellStyle(style); anchor1.setCol1(celda.getColumnIndex()); anchor1.setCol2(celda.getColumnIndex() + 5); anchor1.setRow1(fila.getRowNum()); anchor1.setRow2(fila.getRowNum() + 3); Comment comment = drawing.createCellComment(anchor1); if (f == 0 && c == 0) { RichTextString str = factory.createRichTextString("ADM:\nCampo Obligatorio \n - IDEMPRESA"); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDEMPRESA"); celda.setCellComment(comment); } else if (f == 0 && c == 1) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - IDREGISTROPALETA. \n Debe de tener (15) caracteres"); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDREGISTROPALETA"); celda.setCellComment(comment); } else if (f == 0 && c == 2) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Id del emisor. \n -Debe tener 3 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDEMISOR"); celda.setCellComment(comment); } else if (f == 0 && c == 3) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - id de la operacion.\n -Debe tener 4 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDOPERACION"); celda.setCellComment(comment); } else if (f == 0 && c == 4) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Numero de Operacion.\n -Debe tener 10 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("NUMOPERACION"); celda.setCellComment(comment); } else if (f == 0 && c == 5) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Id del motivo de Paleta.\n -Debe tener 3 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDMOTIVOPALETA"); celda.setCellComment(comment); } else if (f == 0 && c == 6) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Id documento. \n -Debe tener 3 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDDOCUMENTO"); celda.setCellComment(comment); } else if (f == 0 && c == 7) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Serie del Documento. \n -Debe tener 4 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("SERIE"); celda.setCellComment(comment); } else if (f == 0 && c == 8) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Numero de Documento.\n -Debe tener 7 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("NUMERO"); celda.setCellComment(comment); } else if (f == 0 && c == 9) { RichTextString str = factory .createRichTextString("ADM:\nCampo Obligatorio \n - Formato YYYY/MM/DD."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("FECHA"); celda.setCellComment(comment); } else if (f == 0 && c == 10) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Perido del ao \n - fromato YYYYMM."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("PERIODO"); celda.setCellComment(comment); } else if (f == 0 && c == 11) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Id del estado \n -Debe tener 2 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDESTADO"); celda.setCellComment(comment); } else if (f == 0 && c == 12) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Id del cliente o proveedor \n -Debe tener 11 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDCLIEPROV"); celda.setCellComment(comment); } else if (f == 0 && c == 13) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Numero de Paleta \n -Debe tener 20 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("NROPALETA"); celda.setCellComment(comment); } else if (f == 0 && c == 14) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Id de envase \n -Debe tener 3 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDENVASE"); celda.setCellComment(comment); } else if (f == 0 && c == 15) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Id la sucursal \n -Debe tener 3 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDSUCURSAL"); celda.setCellComment(comment); } else if (f == 0 && c == 16) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Id del almacen. \n -Debe tener 3 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDALMACEN"); celda.setCellComment(comment); } else if (f == 0 && c == 17) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Id del embalaje. \n -Debe tener 10 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDEMBALAJE"); celda.setCellComment(comment); } else if (f == 0 && c == 18) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Id de cultivo. \n -Debe tener 4 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDCULTIVO"); celda.setCellComment(comment); } else if (f == 0 && c == 19) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - id de Variadd. \n -Debe tener 3 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDVARIEDAD"); celda.setCellComment(comment); } else if (f == 0 && c == 20) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Observaciones sobre la paleta \n -como maximo 240 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("OBSERVACIONES"); celda.setCellComment(comment); } else if (f == 0 && c == 21) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n -Nombre de la venta \n como maximo 50 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("VENTANA"); celda.setCellComment(comment); } else if (f == 0 && c == 22) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Cantidad. \n - 15 numeros y 2 decimales como maximo."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("CANTIDAD"); celda.setCellComment(comment); } else if (f == 0 && c == 23) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Estado de la paleta \n- 1 = cerrado, 0 = Abierto."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("CERRADO"); celda.setCellComment(comment); } else if (f == 0 && c == 24) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Sincroniza \n - N = no , S = si."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("SINCRONIZA"); celda.setCellComment(comment); } else if (f == 0 && c == 25) { RichTextString str = factory .createRichTextString("ADM:\nCampo Obligatorio \n - Formato YYYY/MM/DD."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("FECHACREACION"); celda.setCellComment(comment); } else if (f == 0 && c == 26) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Numero de Manural\n Debe tener 10 caracteres."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("NROMANUAL"); celda.setCellComment(comment); } else if (f == 0 && c == 27) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - idcliepro-destino\n debe tener 11 caracteres"); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("IDCLIEPROV_DESTINO"); celda.setCellComment(comment); } else if (f == 0 && c == 28) { RichTextString str = factory.createRichTextString( "ADM:\nCampo Obligatorio \n - Tipo de paleta\n debe tener 1 caraccter.."); str.applyFont(font1); str.applyFont(0, 19, font); comment.setString(str); comment.setAuthor("ADM"); celda.setCellValue("TIPO"); celda.setCellComment(comment); } } } hoja.autoSizeColumn((short) 0); hoja.autoSizeColumn((short) 1); hoja.autoSizeColumn((short) 2); hoja.autoSizeColumn((short) 3); hoja.autoSizeColumn((short) 4); hoja.autoSizeColumn((short) 5); hoja.autoSizeColumn((short) 6); hoja.autoSizeColumn((short) 7); hoja.autoSizeColumn((short) 8); hoja.autoSizeColumn((short) 9); hoja.autoSizeColumn((short) 10); hoja.autoSizeColumn((short) 11); hoja.autoSizeColumn((short) 12); hoja.autoSizeColumn((short) 13); hoja.autoSizeColumn((short) 14); hoja.autoSizeColumn((short) 15); hoja.autoSizeColumn((short) 16); hoja.autoSizeColumn((short) 17); hoja.autoSizeColumn((short) 18); hoja.autoSizeColumn((short) 19); hoja.autoSizeColumn((short) 20); hoja.autoSizeColumn((short) 21); hoja.autoSizeColumn((short) 22); hoja.autoSizeColumn((short) 23); hoja.autoSizeColumn((short) 24); hoja.autoSizeColumn((short) 25); hoja.autoSizeColumn((short) 26); hoja.autoSizeColumn((short) 27); hoja.autoSizeColumn((short) 28); for (int f = 0; f < 2; f++) { XSSFRow fila2 = hoja2.createRow(f); if (f == 0) { for (int c = 0; c < 15; c++) { XSSFCell celda2 = fila2.createCell(c); anchor12.setCol1(celda2.getColumnIndex()); anchor12.setCol2(celda2.getColumnIndex() + 8); anchor12.setRow1(fila2.getRowNum()); anchor12.setRow2(fila2.getRowNum() + 8); Comment comment2 = drawing2.createCellComment(anchor12); RichTextString str; switch (c) { case 0: celda2.setCellStyle(style2); str = factory2.createRichTextString( "ADM:\nCampo Obligatorio \n - El Cdigo debe de ser nico."); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("IDEMPRESA"); celda2.setCellComment(comment2); break; case 1: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio "); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("IDREGISTROPALETA"); celda2.setCellComment(comment2); break; case 2: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio "); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("ITEM"); celda2.setCellComment(comment2); break; case 3: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio "); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("IDCLIEPROV"); celda2.setCellComment(comment2); break; case 4: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio"); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("IDLOTE"); celda2.setCellComment(comment2); break; case 5: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio"); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("IDCONDICION"); celda2.setCellComment(comment2); break; case 6: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio"); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("IDTALLA"); celda2.setCellComment(comment2); break; case 7: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio"); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("IDCOLOR"); celda2.setCellComment(comment2); break; case 8: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio"); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("CANTIDAD"); celda2.setCellComment(comment2); break; case 9: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio"); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("IDEMBALAJE"); celda2.setCellComment(comment2); break; case 10: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio"); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("IDPRODUCTO"); celda2.setCellComment(comment2); break; case 11: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio"); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("IDLOTEP"); celda2.setCellComment(comment2); break; case 12: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio"); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("IDCONSUMIDOR"); celda2.setCellComment(comment2); break; case 13: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio"); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("IDLOTECAMPO"); celda2.setCellComment(comment2); break; case 14: celda2.setCellStyle(style2); str = factory.createRichTextString("ADM:\nCampo Obligatorio"); str.applyFont(font12); str.applyFont(0, 19, font2); comment2.setString(str); comment2.setAuthor("ADM"); celda2.setCellValue("IDPRESENTACION"); celda2.setCellComment(comment2); break; } } } } hoja2.autoSizeColumn((short) 0); hoja2.autoSizeColumn((short) 1); hoja2.autoSizeColumn((short) 2); hoja2.autoSizeColumn((short) 3); hoja2.autoSizeColumn((short) 4); hoja2.autoSizeColumn((short) 5); hoja2.autoSizeColumn((short) 6); hoja2.autoSizeColumn((short) 7); hoja2.autoSizeColumn((short) 8); hoja2.autoSizeColumn((short) 9); hoja2.autoSizeColumn((short) 10); hoja2.autoSizeColumn((short) 11); hoja2.autoSizeColumn((short) 12); hoja2.autoSizeColumn((short) 13); hoja2.autoSizeColumn((short) 14); hoja2.autoSizeColumn((short) 15); libro.write(file2); file2.close(); stream = new FileInputStream(new File(rutaArchivo)); arch = new DefaultStreamedContent(stream, "application/xlsx", "FI_REGISTROPALE.xlsx"); } catch (FileNotFoundException ex) { System.out.println("Error al Descargar : " + ex.getMessage()); } return arch; }