You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Nadeesh TV <na...@mdcpartners.be> on 2017/12/18 09:51:15 UTC

Excel row height is not automatically adjusting in LibreOffice

Hi all,

I am using apache poi to create an excel file. Some of the columns 
contain big data and I would like to adjust the row height 
automatically. Please see the sample program which I used.

If I open the generated excel file in*Microsoft Excel and Mac 
OS**Numbers*application then I could see that the row height is adjusted 
automatically but in*LibreOffice*( version 5.4.2.2.) it's not adjusting 
automatically.

I tried the solution|( row.setHeightInPoints((short)-1), 
row.setHeight((short)-1),row.setHeight((short)0) , 
row.setHeightInPoints((short)0))|provided inAuto size height for rows in 
Apache POI 
<https://stackoverflow.com/questions/19145628/auto-size-height-for-rows-in-apache-poi>but 
it did not work.

Any help will be aprreciated


|importorg.apache.poi.xssf.usermodel.*;importjava.io.ByteArrayOutputStream;importjava.io.FileOutputStream;importjava.io.IOException;publicclassWriteExcelBasic{publicstaticvoidmain(String[]args)throwsIOException{StringexcelFileName 
="/Users/home/Test3.xls";FileOutputStreamfos 
=newFileOutputStream(excelFileName);XSSFWorkbookwb 
=newXSSFWorkbook();XSSFCellStylestyle 
=wb.createCellStyle();XSSFSheetsheet 
=wb.createSheet("sheet");XSSFFonturlFont 
=wb.createFont();style.setFont(urlFont);for(intr =0;r <3;r++){XSSFRowrow 
=sheet.createRow(r);row.setHeight((short)-1);for(intc =0;c 
<3;c++){XSSFCellcell =row.createCell(c);Stringss 
="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";cell.setCellValue(ss);style.setWrapText(true);cell.setCellStyle(style);}}try(ByteArrayOutputStreambaos 
=newByteArrayOutputStream()){wb.write(baos);byte[]myByteArray 
=baos.toByteArray();fos.write(myByteArray);fos.flush();}finally{wb.close();fos.close();}}}|

Stack over flow link 
https://stackoverflow.com/questions/47836373/apache-poi-excel-row-height-is-not-automatically-adjusting-in-libreoffice

Regards,
Nadeesh