You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Pablo Casado <pc...@absamail.co.za> on 2003/08/01 10:09:17 UTC
maximum number of font formatting has exceeded
Hi,
I create an excel workbook containing one sheet but then when I open the file in Excel and try to do anything like filtering or charting I get a "No more fonts may be applied in this workbook"
When I create the sheet, based on some criteria I change the backround color of the cell as follows
...
HSSFCellStyle style = cloneStyle(workbook, cell.getCellStyle());
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
style.setFillForegroundColor((new HSSFColor.DARK_RED()).getIndex());
HSSFFont font = workbook.createFont();
font.setColor((new HSSFColor.WHITE()).getIndex());
style.setFont(font);
cell.setCellStyle(style);
...
private HSSFCellStyle cloneStyle(
HSSFWorkbook workbook,
HSSFCellStyle oldStyle) {
HSSFCellStyle newStyle = workbook.createCellStyle();
newStyle.setAlignment( oldStyle.getAlignment() );
newStyle.setDataFormat( oldStyle.getDataFormat() );
newStyle.setFont( workbook.getFontAt(oldStyle.getFontIndex()) );
newStyle.setFillBackgroundColor( oldStyle.getFillBackgroundColor() );
newStyle.setFillForegroundColor( oldStyle.getFillForegroundColor() );
newStyle.setFillPattern( oldStyle.getFillPattern() );
return newStyle;
}
Any help would be appreciated.
- Pablo.