You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Marty <ma...@gmail.com> on 2012/12/05 14:56:21 UTC

RichTextString isn't working for SXSSFWorkbook

Hello,

It looks like RichTextString isn't working for SXSSFWorkbook. See example:
----------------------------------------------------------------------------------------------------------------------

    public Workbook createRichTextWorkbook() {
        Workbook wb = new SXSSFWorkbook();

        Sheet copySheet = wb.createSheet("TestRT");
        Row copyRow = copySheet.createRow(0);
        Cell copyCell = copyRow.createCell(0);


        XSSFFont font1 = (XSSFFont) wb.createFont();
        font1.setFontName("Arial");
        font1.setFontHeightInPoints((short) 12);
        font1.setBold(true);
        font1.setColor(new XSSFColor(new java.awt.Color(255, 0, 0)));

        XSSFFont font2 = (XSSFFont) wb.createFont();
        font2.setFontName("Arial");
        font2.setFontHeightInPoints((short)12);
        font2.setItalic(true);
        font2.setColor(new XSSFColor(new java.awt.Color(0, 255, 0)));


        XSSFRichTextString rt = (XSSFRichTextString)
wb.getCreationHelper().createRichTextString("Hello, World!");
        rt.applyFont( 6, 13, font2 );

        //create a cell style and assign the first font to it
        CellStyle style = wb.createCellStyle();
        style.setFont(font1);
        copyCell.setCellStyle(style);
        copyCell.setCellType(Cell.CELL_TYPE_STRING);
        copyCell.setCellValue(rt);

        return wb;
    }

----------------------------------------------------------------------------------------------------------------------

Thanks,
Marty