poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ook? ook!" <ook1...@gmail.com>
Subject Re: autoSizeColumn mess with fonts
Date Wed, 26 Mar 2008 16:09:01 GMT
Thank you for your information, Mahesh.

Hum... Here some parts of the code:

private static HSSFCellStyle _BOLD_STYLE = null;
    private static HSSFFont _BOLD_FONT = null;

    private HSSFCellStyle getBoldStyle() {
        if (null == _BOLD_STYLE) {
            _BOLD_STYLE = _wb.createCellStyle();
            _BOLD_STYLE.setFont(getBoldFont());
        }
        return _BOLD_STYLE;
    }

    private HSSFFont getBoldFont() {
        if (null == _BOLD_FONT) {
            _BOLD_FONT = _wb.createFont();
            _BOLD_FONT.setFontHeightInPoints((short)10);
            _BOLD_FONT.setColor(HSSFFont.COLOR_NORMAL);
            _BOLD_FONT.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        }
        return _BOLD_FONT;
    }

Then during usage:

HSSFCell c = null;
        _curCellIndex = -1;
        r = _sheet.createRow(++_curRowIndex);
        c = r.createCell(++_curCellIndex);
        final HSSFRichTextString ref = new HSSFRichTextString("Référence");
        c.setCellValue(ref);
        c.setCellStyle(getBoldStyle());

This is done somthing like 13times for "headers" in my sheet.

And once the page is created, I call this:

private void layout() {
        _sheet.setColumnWidth((short)0, (short)2500);
        _sheet.setColumnWidth((short)1, (short)2500);

        for (short i = 2; i < 30; ++i) {
            _sheet.autoSizeColumn(i);
        }
    }

Then autoSizeColumn fire that strange exception.

I think I'm following the same way than you. Can you see a problem in my
lines?

Thank you.

2008/3/26, Mahesh Ganapathy <mganapa@gmail.com>:
>
> (remeber to see
> http://poi.apache.org/hssf/quick-guide.html#WorkingWithFonts for
> resrictions on number of fonts/styles in a workbook)
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message