You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Avinash Kewalramani <AK...@accelrys.com> on 2009/02/25 00:18:54 UTC

Bug in rich text.

Hi

I am trying to work with rich text example from POI and one of my use cases requires text with different font characteristics
in the same cell

The WorkingWithRichText.java example is of great help and exactly provide me with what I need to do.
However I discovred that the font size is not applicable to chunks of rich text. As in the code below I just added the first part of the text to have a size of 22 and it is not displayed

Can any of the authors kindly help with this bug or has it been resolved in Beta 5.I am using Beta 4.

Here is the code with a small change (a single line of code change for font size =22)


XSSFWorkbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();

        XSSFSheet sheet = wb.createSheet();
        XSSFRow row = sheet.createRow((short) 2);

        XSSFCell cell = row.createCell(1);
        XSSFRichTextString rt = new XSSFRichTextString("The quick brown fox");

        XSSFFont font1 = wb.createFont();
        font1.setBold(true);
        font1.setFontHeight((short)22);
        font1.setFontName("Arial");
        font1.setColor(new XSSFColor(new java.awt.Color(255, 0, 0)));
        rt.applyFont(0, 10, font1);

        XSSFFont font2 = wb.createFont();
        font2.setItalic(true);
        font2.setUnderline(XSSFFont.U_DOUBLE);
        font2.setColor(new XSSFColor(new java.awt.Color(0, 255, 0)));
        rt.applyFont(10, 19, font2);

        XSSFFont font3 = wb.createFont();
        font3.setColor(new XSSFColor(new java.awt.Color(0, 0, 255)));
        rt.append(" Jumped over the lazy dog", font3);

        cell.setCellValue(rt);

        // Write the output to a file
        FileOutputStream fileOut = new FileOutputStream("xssf-richtext.xlsx");
        wb.write(fileOut);
        fileOut.close();


Any pointers/help is highly appreciated.
Regards
Avinash




RE: Bug in rich text.

Posted by Avinash Kewalramani <AK...@accelrys.com>.
Hi Dave 
Thanks for the reply.I tried row.setHirght. but that only 
changes the height of the cells in a particular row.What I want is
to have text with multiple font sizes within the same cell.

I also looked at the trunk but i.e v3.2 final but I don't think it has support for 
this feature for .xlsx(XSSF) format files.

Thanks and let me know if you have any other clues.

Regards
A

-----Original Message-----
From: David Fisher [mailto:dfisher@jmlafferty.com] 
Sent: Tuesday, February 24, 2009 4:10 PM
To: POI Users List
Subject: Re: Bug in rich text.

Hi -

Try row.setHeight( 100 );

If that doesn't work then try the trunk.

Regards,
Dave

On Feb 24, 2009, at 3:18 PM, Avinash Kewalramani wrote:

> Hi
>
> I am trying to work with rich text example from POI and one of my  
> use cases requires text with different font characteristics
> in the same cell
>
> The WorkingWithRichText.java example is of great help and exactly  
> provide me with what I need to do.
> However I discovred that the font size is not applicable to chunks  
> of rich text. As in the code below I just added the first part of  
> the text to have a size of 22 and it is not displayed
>
> Can any of the authors kindly help with this bug or has it been  
> resolved in Beta 5.I am using Beta 4.
>
> Here is the code with a small change (a single line of code change  
> for font size =22)
>
>
> XSSFWorkbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
>
>        XSSFSheet sheet = wb.createSheet();
>        XSSFRow row = sheet.createRow((short) 2);
>
>        XSSFCell cell = row.createCell(1);
>        XSSFRichTextString rt = new XSSFRichTextString("The quick  
> brown fox");
>
>        XSSFFont font1 = wb.createFont();
>        font1.setBold(true);
>        font1.setFontHeight((short)22);
>        font1.setFontName("Arial");
>        font1.setColor(new XSSFColor(new java.awt.Color(255, 0, 0)));
>        rt.applyFont(0, 10, font1);
>
>        XSSFFont font2 = wb.createFont();
>        font2.setItalic(true);
>        font2.setUnderline(XSSFFont.U_DOUBLE);
>        font2.setColor(new XSSFColor(new java.awt.Color(0, 255, 0)));
>        rt.applyFont(10, 19, font2);
>
>        XSSFFont font3 = wb.createFont();
>        font3.setColor(new XSSFColor(new java.awt.Color(0, 0, 255)));
>        rt.append(" Jumped over the lazy dog", font3);
>
>        cell.setCellValue(rt);
>
>        // Write the output to a file
>        FileOutputStream fileOut = new FileOutputStream("xssf- 
> richtext.xlsx");
>        wb.write(fileOut);
>        fileOut.close();
>
>
> Any pointers/help is highly appreciated.
> Regards
> Avinash
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Bug in rich text.

Posted by David Fisher <df...@jmlafferty.com>.
Hi -

Try row.setHeight( 100 );

If that doesn't work then try the trunk.

Regards,
Dave

On Feb 24, 2009, at 3:18 PM, Avinash Kewalramani wrote:

> Hi
>
> I am trying to work with rich text example from POI and one of my  
> use cases requires text with different font characteristics
> in the same cell
>
> The WorkingWithRichText.java example is of great help and exactly  
> provide me with what I need to do.
> However I discovred that the font size is not applicable to chunks  
> of rich text. As in the code below I just added the first part of  
> the text to have a size of 22 and it is not displayed
>
> Can any of the authors kindly help with this bug or has it been  
> resolved in Beta 5.I am using Beta 4.
>
> Here is the code with a small change (a single line of code change  
> for font size =22)
>
>
> XSSFWorkbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
>
>        XSSFSheet sheet = wb.createSheet();
>        XSSFRow row = sheet.createRow((short) 2);
>
>        XSSFCell cell = row.createCell(1);
>        XSSFRichTextString rt = new XSSFRichTextString("The quick  
> brown fox");
>
>        XSSFFont font1 = wb.createFont();
>        font1.setBold(true);
>        font1.setFontHeight((short)22);
>        font1.setFontName("Arial");
>        font1.setColor(new XSSFColor(new java.awt.Color(255, 0, 0)));
>        rt.applyFont(0, 10, font1);
>
>        XSSFFont font2 = wb.createFont();
>        font2.setItalic(true);
>        font2.setUnderline(XSSFFont.U_DOUBLE);
>        font2.setColor(new XSSFColor(new java.awt.Color(0, 255, 0)));
>        rt.applyFont(10, 19, font2);
>
>        XSSFFont font3 = wb.createFont();
>        font3.setColor(new XSSFColor(new java.awt.Color(0, 0, 255)));
>        rt.append(" Jumped over the lazy dog", font3);
>
>        cell.setCellValue(rt);
>
>        // Write the output to a file
>        FileOutputStream fileOut = new FileOutputStream("xssf- 
> richtext.xlsx");
>        wb.write(fileOut);
>        fileOut.close();
>
>
> Any pointers/help is highly appreciated.
> Regards
> Avinash
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org