List of usage examples for org.apache.poi.ss.usermodel CellStyle setBorderLeft
void setBorderLeft(BorderStyle border);
From source file:vista.ui.VistaGenerarEstadisticas.java
License:Open Source License
/** * Este mtodo sirve para crear un estilo de celda bsico con un estilo de * borde y color para borde/*w w w. jav a 2s .co m*/ * * @param workbook el objeto Workbook dueo de la celda * @param borderColor el color del borde * @param borderStyle el estilo del borde * @param halign la alineacin horizontal de la celda o un nmero negativo * si no se desea tener alineacin horizontal * @param valign la alineacin vertical de la celda o un nmero negativo si * no se desea tener alineacin vertical * * @return un objeto CellStyle con el estilo de la celda creado */ private CellStyle crearEstiloCelda(Workbook workbook, IndexedColors borderColor, short borderStyle, short halign, short valign) { CellStyle style = workbook.createCellStyle(); //Estilo centrado y con bordes style.setBorderBottom(borderStyle); style.setBottomBorderColor(borderColor.getIndex()); style.setBorderLeft(borderStyle); style.setLeftBorderColor(borderColor.getIndex()); style.setBorderRight(borderStyle); style.setRightBorderColor(borderColor.getIndex()); style.setBorderTop(borderStyle); style.setTopBorderColor(borderColor.getIndex()); if (halign >= 0) { style.setAlignment(halign); style.setVerticalAlignment(valign); } return style; }
From source file:vistas.reportes.procesos.rptVacacionesExcel.java
private Map<String, CellStyle> createStyles(Workbook wb) { Map<String, CellStyle> styles = new HashMap<String, CellStyle>(); CellStyle style; Font titleFont = wb.createFont(); titleFont.setFontHeightInPoints((short) 18); titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); style = wb.createCellStyle();//from ww w . j a v a 2s . c o m style.setAlignment(CellStyle.ALIGN_CENTER); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setFont(titleFont); styles.put("title", style); Font monthFont = wb.createFont(); monthFont.setFontHeightInPoints((short) 11); monthFont.setColor(IndexedColors.WHITE.getIndex()); style = wb.createCellStyle(); style.setAlignment(CellStyle.ALIGN_CENTER); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFont(monthFont); style.setWrapText(true); styles.put("header", style); style = wb.createCellStyle(); style.setAlignment(CellStyle.ALIGN_CENTER); style.setWrapText(true); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderTop(CellStyle.BORDER_THIN); style.setTopBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderBottom(CellStyle.BORDER_THIN); style.setBottomBorderColor(IndexedColors.BLACK.getIndex()); styles.put("cell", style); style = wb.createCellStyle(); style.setAlignment(CellStyle.ALIGN_CENTER); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setDataFormat(wb.createDataFormat().getFormat("0.00")); styles.put("formula", style); style = wb.createCellStyle(); style.setAlignment(CellStyle.ALIGN_CENTER); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setDataFormat(wb.createDataFormat().getFormat("0.00")); styles.put("formula_2", style); return styles; }