Rich text is not supported in SXSSF by design. Excel and XSSF store
strings in a so called Shared Strings Table (SST) which is basically a
cache of strings. When you write a rich text value in a cell then it
is written in the SST and the cell references it by Id. When you read
rich text from a cell, XSSF first fetched sst index from the cell and
then fetches the actual rich text value from SST.
All this means that to support rich text the API needs to keep in
memory a map of strings keyed by their unique ids.

SXSSF is a lightweight API targeting on low memory footprint and
performance. Rich text is converted into plain text and written
directly in the cell. With this trick SXSSF does not need to keep
shared strings which greatly improves performance and memory
consumption.

Yegor

On Wed, Dec 12, 2012 at 9:37 PM, Marat <[email protected]> wrote:
> 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,
> Marat
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to