java - Maping a String to XWPFDocument same as console -


i using xwpfdocument generating .docx invoice. have designed string below on console

    xxxx restaurant & cafe       phone no# 12131546  invoice no. 120 type: c-6 customer name:         29 05 2015 --------------------------------------- product    qty   price   total --------------------------------------- fr. egg+toast but. jam            1  110.0  110.0 --------------------------------------- discount: 0% sub total: 110.0 cash: 200 

my code generating .docx is:

fileoutputstream output = new fileoutputstream(file);                                        xwpfdocument doc = new xwpfdocument();                      xwpfparagraph para = doc.createparagraph();                     para.setalignment(paragraphalignment.center);                      xwpfrun run  = para.createrun();                      run.setbold(true);                      run.setfontsize(11);                       doc.write(output);                      output.close(); 

but generated .docx having text looks like:

"xxxxxx restaurant & cafe phone no# 12313531 invoice no. 120 type: c-6 customer name: 29 05 2015 --------------------------------------- product qty price total --------------------------------------- fr. egg+toast but. jam 1 110.0 110.0 --------------------------------------- discount: 0% sub total: 110.0 cash: 200 balance: 90.0"

i want above stuff same looks on console.please try possible.

i might wrong this. far remember xwpfrun ignores \n in string. therefore trying use run.settext(text) styled text unstyled text unfortunitly. have style text creating runs. might acctually work haven´t tested right now:

xwpfparagraph p = doc.createparagraph(); for(sting s:text.split("\n")){     xwpfrun = p.createrun();     run.settext(s); } 

this won´t preserve style informations string. have generate styled output using xwpfruns.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -