color = Color.decode(facetBackground); HSSFColor backgroundColor = palette.findSimilarColor(color.getRed(), color.getGreen(), color.getBlue()); ((HSSFCellStyle) facetStyle).setFillForegroundColor(backgroundColor.getIndex()); facetStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setFillForegroundColor(HSSFColor.LIME.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
final HSSFCellStyle cell = (HSSFCellStyle) workbook.createCellStyle(); cell .setFillForegroundColor( ... ); cell .setFillPattern( CellStyle.SOLID_FOREGROUND );
//creating a custom palette for the workbook HSSFPalette palette = wb.getCustomPalette(); //replacing the standard red with freebsd.org red palette.setColorAtIndex(HSSFColor.RED.index, (byte) 153, //RGB red (0-255) (byte) 0, //RGB green (byte) 0 //RGB blue ); // or creating a new Color HSSFColor myColor = palette.addColor((byte) 153, (byte) 0, (byte) 0); HSSFCellStyle style = wb.createCellStyle(); style.setFillForegroundColor(myColor);
HSSFCellStyle titleStyle = workbook.createCellStyle(); titleStyle.setFillForegroundColor(MY_DARK_BLUE); titleStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); titleStyle.setFont(fontBold); setTopBotBorder(titleStyle);
private static HSSFCellStyle createMissedStyle(HSSFWorkbook wb) { HSSFCellStyle style = wb.createCellStyle(); style.setFillForegroundColor(HSSFColor.RED.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); return style; }
HSSFCellStyle cellStyle = workbook.createCellStyle(); cellStyle.setFillForegroundColor(HSSFColor.LIGHT_ORANGE.index); cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); for (int i = 0; i < columnNamesFase1.length; i++) { HSSFCell cellA1 = row1.createCell((short) i); cellA1.setCellValue(columnNamesFase1[columnCount]); cellA1.setCellStyle(cellStyle); worksheet.autoSizeColumn(columnCount); columnCount++; }
protected void openWorkbook(OutputStream os) { workbook = new HSSFWorkbook(); emptyCellStyle = workbook.createCellStyle(); emptyCellStyle.setFillForegroundColor((new HSSFColor.WHITE()).getIndex()); emptyCellStyle.setFillPattern(backgroundMode); dataFormat = workbook.createDataFormat(); }
private HSSFCellStyle createStyle(final HSSFWorkbook workbook, boolean isFirst, short align, short color) { HSSFCellStyle style = workbook.createCellStyle(); if (isFirst) { style.setBorderTop(HSSFCellStyle.BORDER_THIN); } if (color != WHITE) { style.setFillForegroundColor(color); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); } if (align == RIGHT) { style.setAlignment(RIGHT); } return style; }
style.setFillPattern(FillPatternType.SOLID_FOREGROUND); HSSFColor hssfColor=buildHSSFColor(wb,bgcolor); style.setFillForegroundColor(hssfColor.getIndex());
private static HSSFCellStyle createTilteStyle(HSSFWorkbook wb) { HSSFFont bold = wb.createFont(); bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); HSSFCellStyle style = wb.createCellStyle(); style.setFont(bold); style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); style.setWrapText(true); return style; }
HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(); HSSFRow row = sheet.createRow((short) 0); HSSFCell cell = row.createCell((short) 0); cell.setCellValue("Default Palette"); //apply some colors from the standard palette, // as in the previous examples. //we'll use red text on a lime background HSSFCellStyle style = wb.createCellStyle(); style.setFillForegroundColor(HSSFColor.LIME.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); HSSFFont font = wb.createFont(); font.setColor(HSSFColor.RED.index); style.setFont(font); cell.setCellStyle(style);
private void greyDataStyleRed(HSSFSheet sheet) { HSSFCellStyle style = sheet.getWorkbook().createCellStyle(); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); style.setWrapText(true); style.setFont(fontRed); styles.put(I_GreyDataStyleRed, style); }
//////////////////////Excel Header Style///////////////////////// HSSFCellStyle headerlabelcs = wb.createCellStyle(); headerlabelcs.setFillForegroundColor(HSSFColor.PALE_BLUE.index); headerlabelcs.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); headerlabelcs.setBorderLeft((short)1); headerlabelcs.setBorderRight((short)1); HSSFFont headerlabelfont = wb.createFont(); headerlabelfont.setFontHeightInPoints((short)12); headerlabelfont.setFontName("Calibri"); headerlabelfont.setColor(HSSFColor.BLACK.index); headerlabelfont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); headerlabelcs.setFont(headerlabelfont); //////////////////////Excel Header Style/////////////////////////
private void greyDataStyleSmall(HSSFSheet sheet) { HSSFCellStyle style = sheet.getWorkbook().createCellStyle(); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); style.setWrapText(true); style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); style.setFont(fontSmall); styles.put(I_GreyDataStyleSmall, style); }
private void greyDataStyle(HSSFSheet sheet) { HSSFCellStyle style = sheet.getWorkbook().createCellStyle(); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); style.setWrapText(true); style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); style.setFont(fontNormal); styles.put(I_GreyDataStyle, style); }
private void changeoverDataStyle(HSSFSheet sheet) { HSSFCellStyle style = sheet.getWorkbook().createCellStyle(); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); style.setWrapText(true); style.setFont(fontNormal); style.setFillForegroundColor(HSSFColor.PALE_BLUE.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); styles.put(I_ChangeoverDataStyle, style); }
private HSSFCellStyle createHeaderStyle(HSSFWorkbook myWorkBook) { Font headerFont = myWorkBook.createFont(); headerFont.setColor(Font.COLOR_NORMAL); HSSFPalette palette = myWorkBook.getCustomPalette(); HSSFColor headerColor = palette.findSimilarColor((byte) 149, (byte) 179, (byte) 215); HSSFCellStyle headerStyle = myWorkBook.createCellStyle(); headerStyle.setFillForegroundColor(headerColor.getIndex()); headerStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); headerStyle.setFont(headerFont); headerStyle.setWrapText(true); return headerStyle; }
private void headerStyle1(HSSFSheet sheet) { HSSFCellStyle style = sheet.getWorkbook().createCellStyle(); style.setBorderTop(HSSFCellStyle.BORDER_MEDIUM); style.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM); style.setBorderRight(HSSFCellStyle.BORDER_MEDIUM); style.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM); style.setFillForegroundColor(HSSFColor.GREY_50_PERCENT.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); style.setAlignment(HSSFCellStyle.ALIGN_LEFT); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); style.setWrapText(true); style.setFont(fontNormal); styles.put(I_HeaderStyle1, style); }
private void greyDataStyleEnd(HSSFSheet sheet) { HSSFCellStyle style = sheet.getWorkbook().createCellStyle(); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); style.setWrapText(true); style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); style.setBorderRight(HSSFCellStyle.BORDER_MEDIUM); style.setFont(fontNormal); styles.put(I_GreyDataStyleEnd, style); }