"HSSFCellStyleProducer will not create more styles. New cells will not have any style.");
return null;
}
}
final CellStyle hssfCellStyle = workbook.createCellStyle();
if (element != null)
{
hssfCellStyle.setAlignment(styleKey.getHorizontalAlignment());
hssfCellStyle.setVerticalAlignment(styleKey.getVerticalAlignment());
hssfCellStyle.setFont(workbook.getFontAt(styleKey.getFont()));
hssfCellStyle.setWrapText(styleKey.isWrapText());
if (styleKey.getDataStyle() >= 0)
{
hssfCellStyle.setDataFormat(styleKey.getDataStyle());
}
}
if (bg != null)
{
if (hssfCellStyle instanceof XSSFCellStyle)
{
final XSSFCellStyle xssfCellStyle = (XSSFCellStyle) hssfCellStyle;
if (BorderStyle.NONE.equals(bg.getBottom().getBorderStyle()) == false)
{
hssfCellStyle.setBorderBottom(styleKey.getBorderStrokeBottom());
xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.BOTTOM,
createXSSFColor(styleKey.getExtendedColorBottom()));
}
if (BorderStyle.NONE.equals(bg.getTop().getBorderStyle()) == false)
{
hssfCellStyle.setBorderTop(styleKey.getBorderStrokeTop());
xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.TOP,
createXSSFColor(styleKey.getExtendedColorTop()));
}
if (BorderStyle.NONE.equals(bg.getLeft().getBorderStyle()) == false)
{
hssfCellStyle.setBorderLeft(styleKey.getBorderStrokeLeft());
xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.LEFT,
createXSSFColor(styleKey.getExtendedColorLeft()));
}
if (BorderStyle.NONE.equals(bg.getRight().getBorderStyle()) == false)
{
hssfCellStyle.setBorderRight(styleKey.getBorderStrokeRight());
xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.RIGHT,
createXSSFColor(styleKey.getExtendedColorRight()));
}
if (bg.getBackgroundColor() != null)
{
xssfCellStyle.setFillForegroundColor(createXSSFColor(styleKey.getExtendedColor()));
hssfCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
}
}
else
{
if (BorderStyle.NONE.equals(bg.getBottom().getBorderStyle()) == false)
{
hssfCellStyle.setBorderBottom(styleKey.getBorderStrokeBottom());
hssfCellStyle.setBottomBorderColor(styleKey.getColorBottom());
}
if (BorderStyle.NONE.equals(bg.getTop().getBorderStyle()) == false)
{
hssfCellStyle.setBorderTop(styleKey.getBorderStrokeTop());
hssfCellStyle.setTopBorderColor(styleKey.getColorTop());
}
if (BorderStyle.NONE.equals(bg.getLeft().getBorderStyle()) == false)
{
hssfCellStyle.setBorderLeft(styleKey.getBorderStrokeLeft());
hssfCellStyle.setLeftBorderColor(styleKey.getColorLeft());
}
if (BorderStyle.NONE.equals(bg.getRight().getBorderStyle()) == false)
{
hssfCellStyle.setBorderRight(styleKey.getBorderStrokeRight());
hssfCellStyle.setRightBorderColor(styleKey.getColorRight());
}
if (bg.getBackgroundColor() != null)
{
hssfCellStyle.setFillForegroundColor(styleKey.getColor());
hssfCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
}
}
}