Arun Kumar Arun Kumar - 2 months ago 6x
Java Question

I need to wrap the text in excel using java

I write some data in excel using java.I need to wrap the particular cell as wrap.can any tell me what is the syntax for wrap text and how can I use it?


In jxl, you have to use setWrap(true):

WritableCellFormat cellFormat = new WritableCellFormat();

sheet.addCell(new Label(1, 1, "A simple test message", cellFormat));    
sheet.addCell(new Label(1, 2, "An other text", cellFormat));


To add a bold cell:

WritableFont cellFont = new WritableFont(WritableFont.COURIER, 16);

WritableCellFormat cellFormatBold = new WritableCellFormat(cellFont);
sheet.addCell(new Label(1, 2, "An other text", cellFormatBold));