package pt.utl.ist.fenix.tools.excel.styles; import java.util.ArrayList; import java.util.List; import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFFont; import org.apache.poi.hssf.usermodel.HSSFWorkbook; public class ComposedCellStyle extends CellStyle { private final List parts = new ArrayList(); @Override public HSSFCellStyle getStyle(HSSFWorkbook book) { HSSFCellStyle style = book.createCellStyle(); HSSFFont font = book.createFont(); for (CellStyle part : parts) { part.appendToStyle(book, style, font); } style.setFont(font); return style; } @Override protected void appendToStyle(HSSFWorkbook book, HSSFCellStyle style, HSSFFont font) { // Nothing to do. } public CellStyle merge(CellStyle style) { parts.add(style); return this; } }