Discussion:
Excel: linebreaks in cells
m***@sdm.de
2007-07-31 15:24:58 UTC
Permalink
Hello everybody,

is it possible to tell a HSSFCell that its content should not extend into the next cell but use multiple lines inside the cell as you can do it in Excel?

Greetings form Germany
Matthias
Luciano Greiner
2007-07-31 15:37:54 UTC
Permalink
I've got the same problem... when trying to insert strings with line
breaks it just cut text and show just the part the fits in column.

Thanks
Post by m***@sdm.de
Hello everybody,
is it possible to tell a HSSFCell that its content should not extend into the next cell but use multiple lines inside the cell as you can do it in Excel?
Greetings form Germany
Matthias
--
Luciano Greiner
Richard Cote
2007-07-31 15:47:20 UTC
Permalink
Post by Luciano Greiner
I've got the same problem... when trying to insert strings with line
breaks it just cut text and show just the part the fits in column.
Thanks
Post by m***@sdm.de
Hello everybody,
is it possible to tell a HSSFCell that its content should not extend into the next cell but use multiple lines inside the cell as you can do it in Excel?
HSSFWorkbook wb = new HSSFWorkbook();
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setWrapText(true);

HSSFSheet sheet = wb.createSheet();
HSSFRow row = row = sheet.createRow((short)0);
HSSFCell cell = row.createCell((short)0)
cell.setCellStyle(cellStyle);
cell.setCellValue(
new HSSFRichTextString(" Line 1 \n Line2 ");
);

Will produce a cell where the text will wrap at the line break.

Cheers,
Rc
--
Richard Cote
Software Engineer - PRIDE Project Team (Sequence Database Group)
European Bioinformatics Institute
Wellcome Trust Genome Campus ***@ebi.ac.uk
Hinxton, Cambridge CB10 1SD Phone: (+44) 1223 492610
United Kingdom Fax : (+44) 1223 494468
Continue reading on narkive:
Loading...