It is a bug which is being fixed.

For now you can use the following temporary workaround:

HSSFRichTextString str = new HSSFRichTextString("text string");
str.applyFont((short)0);  //Excel requires at least one text run. 0 is the 
index of the default font
textbox1.setString( str );

The problem seems to appear only in Excel 2003+. The Excel versions prior to 
2003
are happy to open xls generated by your code.

Yegor

> Hi!! well, I can't insert a HSSFTextbox into a excel File. I can create it
> but when I try to open it excel gets frozen. :sleep:

> here's my code:

> public void testTextBox(){
>     try{
>         HSSFWorkbook hwb = new HSSFWorkbook();
>         HSSFSheet sheet = hwb.createSheet("new sheet");
>         HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
>         HSSFTextbox textbox1 = patriarch.createTextbox
>         (new HSSFClientAnchor(0,0,0,0,(short)1,1,(short)2,2));
>         textbox1.setString(new HSSFRichTextString("text string") );
>         FileOutputStream fileOut = new FileOutputStream
>         ("c:\\createBox.xls");
>         hwb.write(fileOut);
>         fileOut.close();
>         System.out.println("Your excel file has been generated");
>      } catch ( Exception ex ) {System.out.println("Error:
> "+ex.getMessage());}
>     }

> Why is this happening? thanks!!


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to