Styles(SXSSFWorkbook wb) { testNameSuccess = textStyle(wb, createFont(wb, GREEN.getIndex())); testNameFailure = textStyle(wb, createFont(wb, RED.getIndex())); testInfo = textStyle(wb, createFont(wb, GREY_50_PERCENT.getIndex())); header = backgroundStyle(wb, HEADER); resultSuccessId = backgroundStyle(wb, GREEN_MAIN); resultFailureId = backgroundStyle(wb, RED_MAIN); resultSuccessStatus = backgroundStyle(wb, GREEN_MAIN, createFont(wb, GREEN.getIndex())); resultFailureStatus = backgroundStyle(wb, RED_MAIN, createFont(wb, RED.getIndex())); resultSuccess = backgroundStyle(wb, GREEN_FIELDS); resultFailure = backgroundStyle(wb, RED_FIELDS); resultOther = backgroundStyle(wb, null); parametersInfo = textStyle(wb, createFont(wb, BLACK.getIndex())); parameterValue = backgroundStyle(wb, null); parameterAbsent = backgroundStyle(wb, ABSENT_VALUE); }
private CellStyle backgroundStyle(SXSSFWorkbook workbook, Integer rgb) { return backgroundStyle(workbook, rgb, null); }
protected Cell createCell(Row row, int cellNum, Object value, CellStyle style) { Cell cell = row.createCell(cellNum); Object simpleValue = getSimpleValue(value); if (simpleValue != null) { if (simpleValue instanceof Date) { style = styles.getDateStyle(row.getSheet().getWorkbook(), style); cell.setCellValue((Date) simpleValue); } else { cell.setCellValue(FormattersManager.format(simpleValue)); } } cell.setCellStyle(style); return cell; }
SXSSFWorkbook workbook = new CustomizedSXSSFWorkbook(); try { styles = new Styles(workbook); ParameterExport parameterExport = new ParameterExport(styles);
private CellStyle backgroundStyle(SXSSFWorkbook workbook, Integer rgb, Font font) { XSSFCellStyle style = (XSSFCellStyle) workbook.createCellStyle(); if (rgb != null) { IndexedColorMap indexedColors = workbook.getXSSFWorkbook().getStylesSource().getIndexedColors(); XSSFColor color = new XSSFColor(convertRGB(rgb), indexedColors); style.setFillForegroundColor(color); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); } style.setBorderBottom(BorderStyle.THIN); style.setBorderTop(BorderStyle.THIN); style.setBorderLeft(BorderStyle.THIN); style.setBorderRight(BorderStyle.THIN); if (font != null) { style.setFont(font); } style.setWrapText(true); style.setVerticalAlignment(VerticalAlignment.CENTER); return style; }