java - Auto size height for rows in Apache POI / Libre Office issue -
i creating spreadsheet using apache poi. cells have newlines, , want height of cells fits height of content.
i using following code :
public static void main(string[] args) throws ioexception { hssfworkbook workbook=new hssfworkbook(); hssfsheet sheet = workbook.createsheet("amap"); // sheet.autosizecolumn(0); hssfcellstyle style = workbook.createcellstyle(); style.setwraptext(true); addrow(sheet,style, (short) 0); addrow(sheet,style, (short) 1); addrow(sheet,style, (short) 2); fileoutputstream fos = new fileoutputstream("test1.xls"); workbook.write(fos); fos.flush(); fos.close(); system.out.println("ok !"); } private static hssfrow addrow(hssfsheet sheet, hssfcellstyle style, short rownumber) { // hssfrow row = sheet.createrow(rownumber); // row.setrowstyle(style); -- has no effect // row.setheight((short)-1); -- has no effect hssfcell c = row.createcell(0); c.setcellstyle(style); c.setcellvalue("x"); c = row.createcell(1); c.setcellstyle(style); c.setcellvalue( "a\nb\nc"); c = row.createcell(2); c.setcellstyle(style); c.setcellvalue( "y"); return row; }
when open generated file excel, working well.
but when open file open office, first line correct. height of second , third lines small
an idea ?
note : have tried add row.setrowstyle(style); , row.setheight((short)-1); seems have no effect
Comments
Post a Comment