List of usage examples for org.apache.poi.xssf.streaming SXSSFWorkbook getCellStyleAt
@Override public CellStyle getCellStyleAt(int idx)
From source file:com.hauldata.dbpa.file.book.XlsxTargetSheet.java
License:Apache License
/** * Translate styling to workbook CellStyle. * * @param stylesUsed tracks the styles that have been used in the workbook; it will be updated * @param fontsUsed tracks the fonts that have been used in the workbook; it may be updated * @param colorsUsed tracks the colors that have been used in the workbook; it may be updated *///w w w . j a v a 2 s .c o m public CellStyle getCellStyle(SXSSFWorkbook book, Map<StylesWithFormatting, XSSFCellStyle> stylesUsed, Map<FontStyles, XSSFFont> fontsUsed, Map<Integer, XSSFColor> colorsUsed) { XSSFCellStyle cellStyle = stylesUsed.get(this); if (cellStyle != null) { return cellStyle; } cellStyle = (XSSFCellStyle) book.createCellStyle(); cellStyle.cloneStyleFrom(book.getCellStyleAt(formatIndex)); if (styles.bottomBorder.style != null) { cellStyle.setBorderBottom(resolveBorderStyle(styles.bottomBorder)); } if (styles.leftBorder.style != null) { cellStyle.setBorderLeft(resolveBorderStyle(styles.leftBorder)); } if (styles.rightBorder.style != null) { cellStyle.setBorderRight(resolveBorderStyle(styles.rightBorder)); } if (styles.topBorder.style != null) { cellStyle.setBorderTop(resolveBorderStyle(styles.topBorder)); } if (styles.bottomBorder.color != null) { cellStyle.setBottomBorderColor(getColor(styles.bottomBorder.color, book, colorsUsed)); } if (styles.leftBorder.color != null) { cellStyle.setLeftBorderColor(getColor(styles.leftBorder.color, book, colorsUsed)); } if (styles.rightBorder.color != null) { cellStyle.setRightBorderColor(getColor(styles.rightBorder.color, book, colorsUsed)); } if (styles.topBorder.color != null) { cellStyle.setTopBorderColor(getColor(styles.topBorder.color, book, colorsUsed)); } if (styles.backgroundColor != null) { cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); cellStyle.setFillForegroundColor(getColor(styles.backgroundColor, book, colorsUsed)); } if (styles.textAlign != null) { cellStyle.setAlignment(styles.textAlign); } if (!styles.font.areDefault()) { cellStyle.setFont(getFont(styles.font, book, fontsUsed, colorsUsed)); } stylesUsed.put(this, cellStyle); return cellStyle; }