poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Meghana <sy...@yahoo.com>
Subject RE: Multi line text
Date Wed, 07 Jun 2006 14:03:53 GMT
Nidhi,
Thanks for a detailed reply. When I set wrapText to true, doesn't it automatically format
the text with new lines? In other words do I have to explicitly format the text by inserting
new lines?

Thanks again,
-M

Nidhi Tuli <ntuli@paymentone.com> wrote: You can look at http://jakarta.apache.org/poi/hssf/quick-guide.html


Using newlines in cells
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet s = wb.createSheet();
    HSSFRow r = null;
    HSSFCell c = null;
    HSSFCellStyle cs = wb.createCellStyle();
    HSSFFont f = wb.createFont();
    HSSFFont f2 = wb.createFont();

    cs = wb.createCellStyle();

    cs.setFont( f2 );
    //Word Wrap MUST be turned on
    cs.setWrapText( true );

    r = s.createRow( (short) 2 );
    r.setHeight( (short) 0x349 );
    c = r.createCell( (short) 2 );
    c.setCellType( HSSFCell.CELL_TYPE_STRING );
    c.setCellValue( "Use \n with word wrap on to create a new line" );
    c.setCellStyle( cs );
    s.setColumnWidth( (short) 2, (short) ( ( 50 * 8 ) / ( (double) 1 /
20 ) ) );

    FileOutputStream fileOut = new FileOutputStream( "workbook.xls" );
    wb.write( fileOut );
    fileOut.close();

Hope this helps
Nidhi

-----Original Message-----
From: Meghana [mailto:sy62k@yahoo.com] 
Sent: Tuesday, June 06, 2006 3:40 PM
To: poi-user@jakarta.apache.org
Subject: Multi line text

Hi,
   Does any one know how to out put the text in multiple lines in a
cell? In each row only two cells will have large text running into
multiple lines. 

Any help is appreciated,
Thanks,
-M

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/



 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message