List of usage examples for org.apache.poi.xssf.usermodel DefaultIndexedColorMap DefaultIndexedColorMap
DefaultIndexedColorMap
From source file:br.com.tecsinapse.dataio.style.TableCellStyle.java
License:LGPL
public CellStyle toCellStyle(Workbook wb) { CellStyle cellStyle = wb.createCellStyle(); final HSSFColor bgColor = getBackgroundColor(); if (bgColor != null) { if (cellStyle instanceof XSSFCellStyle) { ((XSSFCellStyle) cellStyle)/* w ww . j ava 2 s. c o m*/ .setFillForegroundColor(new XSSFColor(toAwtColor(bgColor), new DefaultIndexedColorMap())); } else { cellStyle.setFillForegroundColor(getBackgroundColor().getIndex()); } cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); } if (getBorder() != null) { cellStyle = border.toCellStyle(cellStyle); } if (getVAlign() != null) { cellStyle.setVerticalAlignment(vAlign.getCellStyleVAlign()); } if (getHAlign() != null) { cellStyle.setAlignment(hAlign.getCellStyleHAlign()); } cellStyle.setWrapText(isWrapText()); Font font = wb.createFont(); configFont(font); cellStyle.setFont(font); if (cellFormat != null && !cellFormat.isEmpty()) { cellStyle.setDataFormat(wb.createDataFormat().getFormat(cellFormat)); } return cellStyle; }