Example usage for org.apache.poi.hssf.usermodel HSSFCellStyle setFillPattern

List of usage examples for org.apache.poi.hssf.usermodel HSSFCellStyle setFillPattern

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFCellStyle setFillPattern.

Prototype

@Override
public void setFillPattern(FillPatternType fp) 

Source Link

Document

setting to one fills the cell with the foreground color...

Usage

From source file:org.kurator.validation.actors.io.AnalysisSpreadsheetBuilder.java

License:Open Source License

/**
 * Initialize styles to be used when generating the spreadsheet. Each background color maps to
 * a particular validation state (CORRECT, CURATED, UNABLE_CURATE, UNABLE_DETERMINE_VALIDITY, etc)
 *///from   ww  w.j av  a2 s  .  co m
private void initStyles() {
    HSSFPalette palette = wb.getCustomPalette();

    HSSFColor red = palette.findSimilarColor(255, 145, 145);
    HSSFColor green = palette.findSimilarColor(156, 255, 153);
    HSSFColor yellow = palette.findSimilarColor(255, 248, 153);
    HSSFColor yellow4 = palette.findSimilarColor(230, 230, 76);
    HSSFColor grey = palette.findSimilarColor(204, 204, 204);
    HSSFColor sun4 = palette.findSimilarColor(204, 204, 255);

    HSSFCellStyle unableCurateCellStyle = wb.createCellStyle();
    unableCurateCellStyle.setFillForegroundColor(red.getIndex());
    unableCurateCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

    HSSFCellStyle correctCellStyle = wb.createCellStyle();
    correctCellStyle.setFillForegroundColor(green.getIndex());
    correctCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

    HSSFCellStyle curatedCellStyle = wb.createCellStyle();
    curatedCellStyle.setFillForegroundColor(yellow.getIndex());
    curatedCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

    HSSFCellStyle filledinCellStyle = wb.createCellStyle();
    filledinCellStyle.setFillForegroundColor(yellow4.getIndex());
    filledinCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

    HSSFCellStyle unableDetermineValidityCellStyle = wb.createCellStyle();
    unableDetermineValidityCellStyle.setFillForegroundColor(grey.getIndex());
    unableDetermineValidityCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

    validationStateStyles = new HashMap<String, HSSFCellStyle>();

    validationStateStyles.put("UNABLE_DETERMINE_VALIDITY", unableDetermineValidityCellStyle);
    validationStateStyles.put("CURATED", curatedCellStyle);
    validationStateStyles.put("CORRECT", correctCellStyle);
    validationStateStyles.put("FILLED_IN", filledinCellStyle);
    validationStateStyles.put("UNABLE_CURATE", unableCurateCellStyle);
}

From source file:org.metaeffekt.core.inventory.processor.writer.InventoryWriter.java

License:Apache License

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);/* w  w  w. jav  a 2  s . c o  m*/
    headerStyle.setWrapText(true);
    return headerStyle;
}

From source file:org.ofbiz.webtools.ExcelConversionFilter.java

License:Open Source License

void applyStylesToSheet(Map<String, ? extends Object> context, HSSFWorkbook workBook, HSSFSheet sheet,
        ServletRequest request) {//from ww w . ja v a2  s .c  o  m
    List headerKeys = new ArrayList();
    int noOfheads = 0;
    headerKeys = UtilMisc.toList("mainHeader1", "mainHeader2", "mainHeader3", "mainHeader4", "mainHeader5");
    Map<String, Object> stylesMap = FastMap.newInstance();
    stylesMap = (Map) context.get("stylesMap");
    ArrayList allRowAndColData = (ArrayList) context.get("allRowAndColData");
    Integer mainHeadingCell = 5;
    Integer mainHeadercellHeight = null;
    String mainHeaderFontName = null;
    Integer mainHeaderFontSize = null;
    Boolean mainHeaderBold = true;
    Integer columnHeaderCellHeight = null;
    Boolean columnHeaderBold = true;
    Boolean columnHeaderBgColor = null;
    String columnHeaderFontName = null;
    Boolean autoSizeCell = true;
    Integer columnHeaderFontSize = null;
    mainHeadercellHeight = (Integer) stylesMap.get("mainHeadercellHeight");
    mainHeaderFontName = (String) stylesMap.get("mainHeaderFontName");
    mainHeaderFontSize = (Integer) stylesMap.get("mainHeaderFontSize");
    if (stylesMap.get("mainHeaderBold") != null) {
        mainHeaderBold = (Boolean) stylesMap.get("mainHeaderBold");
    }
    if (stylesMap.get("columnHeaderBold") != null) {
        columnHeaderBold = (Boolean) stylesMap.get("columnHeaderBold");
    }
    if (stylesMap.get("autoSizeCell") != null) {
        autoSizeCell = (Boolean) stylesMap.get("autoSizeCell");
    }
    if (stylesMap.get("mainHeadingCell") != null) {
        mainHeadingCell = (Integer) stylesMap.get("mainHeadingCell");
    }
    columnHeaderCellHeight = (Integer) stylesMap.get("columnHeaderCellHeight");
    columnHeaderBgColor = (Boolean) stylesMap.get("columnHeaderBgColor");
    columnHeaderFontName = (String) stylesMap.get("columnHeaderFontName");
    columnHeaderFontSize = (Integer) stylesMap.get("columnHeaderFontSize");
    ArrayList styles = new ArrayList(stylesMap.keySet());
    for (int i = 0; i < styles.size(); i++) {
        ArrayList tempArrayList = new ArrayList<String>();
        if (headerKeys.contains(styles.get(i))) {
            ArrayList<?> innerData = (ArrayList<?>) allRowAndColData.get(i);
            tempArrayList.add(stylesMap.get(styles.get(i)));
            for (int j = 0; j < innerData.size() - 1; j++) {
                tempArrayList.add("");
            }
            allRowAndColData.add(i, tempArrayList);
            ++noOfheads;
        }
    }
    try {
        for (int i = 0; i < allRowAndColData.size(); i++) {
            HSSFCellStyle style = workBook.createCellStyle();
            HSSFFont font = workBook.createFont();
            ArrayList<?> ardata = (ArrayList<?>) allRowAndColData.get(i);
            HSSFRow row = sheet.createRow(i);
            for (int k = 0; k < ardata.size(); k++) {
                HSSFCell cell = row.createCell(k);
                if (k == mainHeadingCell && i <= noOfheads) {
                    if (UtilValidate.isNotEmpty(mainHeadercellHeight)) {
                        row.setHeight((short) mainHeadercellHeight.shortValue());
                    } else {
                        row.setHeight((short) 400);
                    }
                    if (UtilValidate.isNotEmpty(mainHeaderFontName)) {
                        font.setFontName(mainHeaderFontName);
                    }
                    if (UtilValidate.isNotEmpty(mainHeaderBold) && mainHeaderBold) {
                        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
                    }
                    if (UtilValidate.isNotEmpty(mainHeaderFontSize)) {
                        font.setFontHeightInPoints((short) mainHeaderFontSize.shortValue());
                    } else {
                        font.setFontHeightInPoints((short) 12); //default value 
                    }
                    style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
                    style.setFont(font);
                    cell.setCellValue((ardata.get(0).toString()).replaceAll("\"", ""));
                    cell.setCellStyle(style);
                } else if (i == noOfheads + 1) {
                    if (UtilValidate.isNotEmpty(columnHeaderCellHeight)) {
                        row.setHeight((short) columnHeaderCellHeight.shortValue());
                    } else {
                        row.setHeight((short) 300);
                    }
                    if (UtilValidate.isNotEmpty(columnHeaderBold) && columnHeaderBold) {
                        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
                    }
                    if (UtilValidate.isNotEmpty(columnHeaderFontSize)) {
                        font.setFontHeightInPoints((short) columnHeaderFontSize.shortValue());
                    } else {
                        font.setFontHeightInPoints((short) 9);
                    }
                    if (UtilValidate.isNotEmpty(columnHeaderFontName)) {
                        font.setFontName(columnHeaderFontName);
                    }
                    if (UtilValidate.isNotEmpty(columnHeaderBgColor) && columnHeaderBgColor) {
                        style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
                    }
                    style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
                    style.setFont(font);
                    cell.setCellValue((ardata.get(k).toString()).replaceAll("\"", ""));
                    cell.setCellStyle(style);
                } else if (i > noOfheads) {
                    cell.setCellValue((ardata.get(k).toString()).replaceAll("\"", ""));
                }
                if (UtilValidate.isNotEmpty(autoSizeCell) && autoSizeCell) {
                    sheet.autoSizeColumn(k);
                }
            }
        }
    } catch (Exception e) {
        Debug.logInfo(e.getMessage(), module);
        request.setAttribute("_ERROR_MESSAGE_", e.getMessage());

    }
}

From source file:org.openmrs.module.kenyaemr.export.ExportLayouter.java

License:Open Source License

/**
 * Builds the column headers/*from  w  w  w .j a  v  a  2 s.  c  o m*/
 * 
 * @param worksheet
 * @param startRowIndex
 *            starting row offset
 * @param startColIndex
 *            starting column offset
 */
public static void buildHeaders(HSSFSheet worksheet, int startRowIndex, int startColIndex) {

    // Create font style for the headers
    Font font = worksheet.getWorkbook().createFont();
    font.setBoldweight(Font.BOLDWEIGHT_BOLD);

    // Create cell style for the headers
    HSSFCellStyle headerCellStyle = worksheet.getWorkbook().createCellStyle();
    headerCellStyle.setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index);
    headerCellStyle.setFillPattern(CellStyle.FINE_DOTS);
    headerCellStyle.setAlignment(CellStyle.ALIGN_CENTER);
    headerCellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    headerCellStyle.setWrapText(true);
    headerCellStyle.setFont(font);
    headerCellStyle.setBorderBottom(CellStyle.BORDER_THIN);

    // Create the column headers
    HSSFRow rowHeader = worksheet.createRow((short) startRowIndex + 2);
    rowHeader.setHeight((short) 500);

    HSSFCell cell1 = rowHeader.createCell(startColIndex + 0);
    cell1.setCellValue("Order Date");
    cell1.setCellStyle(headerCellStyle);

    HSSFCell cell2 = rowHeader.createCell(startColIndex + 1);
    cell2.setCellValue("Patient Identifier");
    cell2.setCellStyle(headerCellStyle);

    HSSFCell cell3 = rowHeader.createCell(startColIndex + 2);
    cell3.setCellValue("Name");
    cell3.setCellStyle(headerCellStyle);

    HSSFCell cell4 = rowHeader.createCell(startColIndex + 3);
    cell4.setCellValue("Age");
    cell4.setCellStyle(headerCellStyle);

    HSSFCell cell5 = rowHeader.createCell(startColIndex + 4);
    cell5.setCellValue("Gender");
    cell5.setCellStyle(headerCellStyle);

    HSSFCell cell6 = rowHeader.createCell(startColIndex + 5);
    cell6.setCellValue("Sample No.");
    cell6.setCellStyle(headerCellStyle);

    HSSFCell cell7 = rowHeader.createCell(startColIndex + 6);
    cell7.setCellValue("Lab");
    cell7.setCellStyle(headerCellStyle);

    HSSFCell cell8 = rowHeader.createCell(startColIndex + 7);
    cell8.setCellValue("Test");
    cell8.setCellStyle(headerCellStyle);

    HSSFCell cell9 = rowHeader.createCell(startColIndex + 8);
    cell9.setCellValue("Test name");
    cell9.setCellStyle(headerCellStyle);

    HSSFCell cell10 = rowHeader.createCell(startColIndex + 9);
    cell10.setCellValue("Result");
    cell10.setCellStyle(headerCellStyle);
}

From source file:org.orbeon.oxf.util.XLSUtils.java

License:Open Source License

public static void copyCell(HSSFWorkbook workbook, HSSFCell destination, HSSFCell source) {

    // Copy cell content
    destination.setCellType(source.getCellType());
    switch (source.getCellType()) {
    case HSSFCell.CELL_TYPE_BOOLEAN:
        destination.setCellValue(source.getBooleanCellValue());
        break;//  w  ww.j a  va  2s.c o m
    case HSSFCell.CELL_TYPE_FORMULA:
    case HSSFCell.CELL_TYPE_STRING:
        destination.setCellValue(source.getStringCellValue());
        break;
    case HSSFCell.CELL_TYPE_NUMERIC:
        destination.setCellValue(source.getNumericCellValue());
        break;
    }

    // Copy cell style
    HSSFCellStyle sourceCellStyle = source.getCellStyle();
    HSSFCellStyle destinationCellStyle = workbook.createCellStyle();
    destinationCellStyle.setAlignment(sourceCellStyle.getAlignment());
    destinationCellStyle.setBorderBottom(sourceCellStyle.getBorderBottom());
    destinationCellStyle.setBorderLeft(sourceCellStyle.getBorderLeft());
    destinationCellStyle.setBorderRight(sourceCellStyle.getBorderRight());
    destinationCellStyle.setBorderTop(sourceCellStyle.getBorderTop());
    destinationCellStyle.setBottomBorderColor(sourceCellStyle.getBottomBorderColor());
    destinationCellStyle.setDataFormat(sourceCellStyle.getDataFormat());
    destinationCellStyle.setFillBackgroundColor(sourceCellStyle.getFillForegroundColor());
    destinationCellStyle.setFillForegroundColor(sourceCellStyle.getFillForegroundColor());
    destinationCellStyle.setFillPattern(sourceCellStyle.getFillPattern());
    destinationCellStyle.setFont(workbook.getFontAt(sourceCellStyle.getFontIndex()));
    destinationCellStyle.setHidden(sourceCellStyle.getHidden());
    destinationCellStyle.setIndention(sourceCellStyle.getIndention());
    destinationCellStyle.setLeftBorderColor(sourceCellStyle.getLeftBorderColor());
    destinationCellStyle.setLocked(sourceCellStyle.getLocked());
    destinationCellStyle.setRightBorderColor(sourceCellStyle.getRightBorderColor());
    destinationCellStyle.setRotation(sourceCellStyle.getRotation());
    destinationCellStyle.setTopBorderColor(sourceCellStyle.getTopBorderColor());
    destinationCellStyle.setVerticalAlignment(sourceCellStyle.getVerticalAlignment());
    destinationCellStyle.setWrapText(sourceCellStyle.getWrapText());
    destination.setCellStyle(destinationCellStyle);
}

From source file:org.sevenorcas.style.app.mod.ss.SpreadSheet.java

/**
 * Set a cell style as header//from   w ww.  j ava 2 s.co m
 * 
 * Thanks to http://www.experts-exchange.com/Programming/Languages/Java/Q_24242777.html
 * 
 * @param workbook
 * @param style id
 * @param rowStyle
 * @param column
 * @param wb
 * @return
 */
protected void setStyleHeader(HSSFWorkbook wb, HSSFCellStyle style, int styleId) { //EX1, int row, int column, SpreadsheetCell cell){
    HSSFFont font = wb.createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    style.setFont(font);
    style.setLocked(true);
    style.setBottomBorderColor(HSSFColor.WHITE.index);
    style.setLeftBorderColor(HSSFColor.WHITE.index);
    style.setRightBorderColor(HSSFColor.WHITE.index);
    style.setTopBorderColor(HSSFColor.WHITE.index);
    style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
    style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
}

From source file:padrao.Run.java

public static void main(String[] args) {
    try {//  ww w.  j av  a2 s.c  o  m
        FileOutputStream fileOut = new FileOutputStream("poi-test.xls");
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet worksheet = workbook.createSheet("POI Worksheet");

        // index from 0,0... cell A1 is cell(0,0)
        HSSFRow row1 = worksheet.createRow((short) 0);

        HSSFCell cellA1 = row1.createCell((short) 0);
        cellA1.setCellValue("Hello");
        HSSFCellStyle cellStyle = workbook.createCellStyle();
        cellStyle.setFillForegroundColor(HSSFColor.GOLD.index);
        cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
        cellA1.setCellStyle(cellStyle);

        HSSFCell cellB1 = row1.createCell((short) 1);
        cellB1.setCellValue("Goodbye");
        cellStyle = workbook.createCellStyle();
        cellStyle.setFillForegroundColor(HSSFColor.LIGHT_CORNFLOWER_BLUE.index);
        cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
        cellB1.setCellStyle(cellStyle);

        HSSFCell cellC1 = row1.createCell((short) 2);
        cellC1.setCellValue(true);

        HSSFCell cellD1 = row1.createCell((short) 3);
        cellD1.setCellValue(new Date());
        cellStyle = workbook.createCellStyle();
        cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));
        cellD1.setCellStyle(cellStyle);

        workbook.write(fileOut);
        fileOut.flush();
        fileOut.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:pe.gob.mef.gescon.web.ui.BaseLegalMB.java

public void postProcessXLS(Object document) {
    HSSFWorkbook wb = (HSSFWorkbook) document;
    HSSFSheet sheet = wb.getSheetAt(0);// w ww. jav  a2 s  .com

    //Para los datos
    HSSFCellStyle centerStyle = wb.createCellStyle();
    centerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);

    HSSFCellStyle centerGrayStyle = wb.createCellStyle();
    centerGrayStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    centerGrayStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
    centerGrayStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);

    HSSFCellStyle grayBG = wb.createCellStyle();
    grayBG.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
    grayBG.setFillPattern(CellStyle.SOLID_FOREGROUND);
    int i = 1;
    for (BaseLegal b : this.getListaBaseLegal()) {
        HSSFRow row = sheet.getRow(i);
        for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) {
            HSSFCell cell = row.getCell(j);
            if (i % 2 == 0) {
                if (j > 0) {
                    cell.setCellStyle(centerGrayStyle);
                } else {
                    cell.setCellStyle(grayBG);
                    cell.setCellValue(b.getVnumero());
                }
            } else {
                if (j > 0) {
                    cell.setCellStyle(centerStyle);
                } else {
                    cell.setCellValue(b.getVnumero());
                }
            }
        }
        i++;
    }

    // Para la cabecera
    HSSFRow header = sheet.getRow(0);
    HSSFCellStyle headerStyle = wb.createCellStyle();
    HSSFFont font = wb.createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    headerStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    headerStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
    headerStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    headerStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
    headerStyle.setFont(font);

    for (int j = 0; j < header.getPhysicalNumberOfCells(); j++) {
        HSSFCell cell = header.getCell(j);
        cell.setCellStyle(headerStyle);
        sheet.autoSizeColumn(j);
    }
}

From source file:pe.gob.mef.gescon.web.ui.BuenaPracticaMB.java

public void postProcessXLS(Object document) {
    HSSFWorkbook wb = (HSSFWorkbook) document;
    HSSFSheet sheet = wb.getSheetAt(0);/*ww  w.j  a  v a2 s . c  om*/

    //Para los datos
    HSSFCellStyle centerStyle = wb.createCellStyle();
    centerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);

    HSSFCellStyle centerGrayStyle = wb.createCellStyle();
    centerGrayStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    centerGrayStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
    centerGrayStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);

    HSSFCellStyle grayBG = wb.createCellStyle();
    grayBG.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
    grayBG.setFillPattern(CellStyle.SOLID_FOREGROUND);
    int i = 1;
    for (Conocimiento c : this.getListaBuenaPractica()) {
        HSSFRow row = sheet.getRow(i);
        for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) {
            HSSFCell cell = row.getCell(j);
            if (i % 2 == 0) {
                if (j > 0) {
                    cell.setCellStyle(centerGrayStyle);
                } else {
                    cell.setCellStyle(grayBG);
                    cell.setCellValue(c.getVtitulo());
                }
            } else {
                if (j > 0) {
                    cell.setCellStyle(centerStyle);
                } else {
                    cell.setCellValue(c.getVtitulo());
                }
            }
        }
        i++;
    }

    // Para la cabecera
    HSSFRow header = sheet.getRow(0);
    HSSFCellStyle headerStyle = wb.createCellStyle();
    HSSFFont font = wb.createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    headerStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    headerStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
    headerStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    headerStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
    headerStyle.setFont(font);

    for (int j = 0; j < header.getPhysicalNumberOfCells(); j++) {
        HSSFCell cell = header.getCell(j);
        cell.setCellStyle(headerStyle);
        sheet.autoSizeColumn(j);
    }
}

From source file:pe.gob.mef.gescon.web.ui.ContenidoMB.java

public void postProcessXLS(Object document) {
    HSSFWorkbook wb = (HSSFWorkbook) document;
    HSSFSheet sheet = wb.getSheetAt(0);//w  ww .  j av  a  2 s .  c  o m

    //Para los datos
    HSSFCellStyle centerStyle = wb.createCellStyle();
    centerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);

    HSSFCellStyle centerGrayStyle = wb.createCellStyle();
    centerGrayStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    centerGrayStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
    centerGrayStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);

    HSSFCellStyle grayBG = wb.createCellStyle();
    grayBG.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
    grayBG.setFillPattern(CellStyle.SOLID_FOREGROUND);
    int i = 1;
    for (Conocimiento c : this.getListaContenido()) {
        HSSFRow row = sheet.getRow(i);
        for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) {
            HSSFCell cell = row.getCell(j);
            if (i % 2 == 0) {
                if (j > 0) {
                    cell.setCellStyle(centerGrayStyle);
                } else {
                    cell.setCellStyle(grayBG);
                    cell.setCellValue(c.getVtitulo());
                }
            } else {
                if (j > 0) {
                    cell.setCellStyle(centerStyle);
                } else {
                    cell.setCellValue(c.getVtitulo());
                }
            }
        }
        i++;
    }

    // Para la cabecera
    HSSFRow header = sheet.getRow(0);
    HSSFCellStyle headerStyle = wb.createCellStyle();
    HSSFFont font = wb.createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    headerStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    headerStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
    headerStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    headerStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
    headerStyle.setFont(font);

    for (int j = 0; j < header.getPhysicalNumberOfCells(); j++) {
        HSSFCell cell = header.getCell(j);
        cell.setCellStyle(headerStyle);
        sheet.autoSizeColumn(j);
    }
}