List of usage examples for org.apache.poi.xssf.usermodel XSSFCellStyle XSSFCellStyle
public XSSFCellStyle(int cellXfId, int cellStyleXfId, StylesTable stylesSource, ThemesTable theme)
From source file:com.miraisolutions.xlconnect.XCellStyle.java
License:Open Source License
public static void set(XSSFCell c, XCellStyle cs) { if (cs.xfId < 0) { // Only the style xf is of interest CTXf styleXf = cs.getStyleXf();/*w w w . j a va2 s .c o m*/ CTXf xf = CTXf.Factory.newInstance(); xf.setNumFmtId(styleXf.getNumFmtId()); xf.setFontId(styleXf.getFontId()); xf.setFillId(styleXf.getFillId()); xf.setBorderId(styleXf.getBorderId()); xf.setAlignment(styleXf.getAlignment()); xf.setXfId(cs.styleXfId); int xfSize = cs.workbook.getStylesSource().putCellXf(xf); c.setCellStyle(new XSSFCellStyle(xfSize - 1, cs.styleXfId, cs.workbook.getStylesSource(), cs.workbook.getTheme())); } else if (cs.styleXfId < 0) { // It's an unnamed cell style - only the core xf is of interest int styleXfId = 0; int id = (int) cs.workbook.getStylesSource().getCellXfAt(cs.xfId).getXfId(); if (id > 0) styleXfId = id; c.setCellStyle( new XSSFCellStyle(cs.xfId, styleXfId, cs.workbook.getStylesSource(), cs.workbook.getTheme())); } else c.setCellStyle(new XSSFCellStyle(cs.xfId, cs.styleXfId, cs.workbook.getStylesSource(), cs.workbook.getTheme())); }