ms word - Controlling table row height for document in poi -



ms word - Controlling table row height for document in poi -

i trying draw table in poi using xwpf component using below code

// inputstream in= temp.class.getresourceasstream("sample.docx"); xwpfdocument doc = new xwpfdocument(); xwpftable table=doc.createtable(2,2); // ctdecimalnumber rowsize = table.getcttbl().gettblpr().gettblstylerowbandsize(); // rowsize.setval(new biginteger("10")); // table.getrow(1).setheight(0); table.getrow(0).getcell(0).settext("row-0-cell-0"); table.getrow(0).getcell(1).settext("row-0-cell-1"); table.getrow(1).getcell(0).settext("row-1-cell-0"); table.getrow(1).getcell(1).settext("row-1-cell-1"); fileoutputstream out = new fileoutputstream("simpletable.docx"); doc.write(out); out.close();

it draws table height of cells big , width not falls in place. saw in note table supposed auto fit per content. tried couple of things follows:

tried setting height shown in commented code above did not worked. tried reading existing doc shown in inputstream commented code. gave exception not read poi-ooxml file. tried using tblstylerowbandsize remains null. not sure how create new instance of ctdecimalnumber or tblstylerowbandsize

thanks in advance.

some more insight: when create empty table, , add together rows , column using create, works fine , not inserts formatting character. making empty table results in cell created @ begining , still trying find way remove first column. new code

xwpftable table=doc.createtable(); xwpftablerow row1 = table.createrow(); row1.createcell().settext("row-0-cell-0"); row1.createcell().settext("row-0-cell-1"); xwpftablerow row2 = table.createrow(); row2.createcell().settext("row-1-cell-0"); row2.createcell().settext("row-1-cell-1");

i'm not sure on of query, can help lastly bit, you'll want like:

if(! table.gettblpr().issettblstylerowbandsize()) { table.gettblpr().addnewtblstylerowbandsize(); } system.out.println("was " + table.gettblpr().gettblstylerowbandsize().getval()); table.gettblpr().gettblstylerowbandsize().setval(new biginteger("12345")); system.out.println("now " + table.gettblpr().gettblstylerowbandsize().getval());

ms-word apache-poi doc

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -