java - XWPFRun.setText() doesn't seem to respect line breaks or tabs? -
here sample code, "\t" not work settext method?:
xwpfdocument document = new xwpfdocument(); xwpfparagraph tp = document.createparagraph(); xwpfrun trun = tp.createrun(); trun.settext("a"); trun.settext("\t"); // not work trun.settext("b"); fileoutputstream outstream = null; try { outstream = new fileoutputstream("testtabwithpoi.doc"); document.write(outstream); outstream.close(); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); }
that isn't how add tabs or newlines run. way microsoft words generates files add special break style elements, , therefore that's need in apache poi too, since that's how format works.
you can see example of adding tags in testaddtabsandlinebreaks() of testxwpfrun. code needs be:
xwpfrun trun = tp.createrun(); trun.settext("a"); trun.addtab(); trun.settext("b"); (you'll need using new copy of apache poi addtab() support)
Comments
Post a Comment