Arun Kumar Arun Kumar - 1 year ago 90
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?

Answer Source

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));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download