Java Apache POI Tab Stop word document

故事扮演 提交于 2019-12-13 02:37:11

问题


I have a word document that has lines like the following A name (aligned left) and a price (aligned all the way to the right) both on the same line. I believe this is done by a tab-stop in a word document. Here is an example, see the first line.

Is it possible for me to print out into a word document, a line like the first one? I checked around the documentation for apache POI but didn't see anything that allowed you to set a tab stop. However, I wasn't sure if there is another way to get the first line to look like that.

回答1:


I used this method to add tabs stops

public static void setTabStop(XWPFParagraph oParagraph, STTabJc.Enum oSTTabJc, BigInteger oPos)
{
    CTP oCTP = oParagraph.getCTP();
    CTPPr oPPr = oCTP.getPPr();
    if(oPPr == null)
    {
      oPPr = oCTP.addNewPPr();
    }

    CTTabs oTabs = oPPr.getTabs();
    if(oTabs == null)
    {
      oTabs = oPPr.addNewTabs();
    }

    CTTabStop oTabStop = oTabs.addNewTab();
    oTabStop.setVal(oSTTabJc);
    oTabStop.setPos(oPos);
}


来源:https://stackoverflow.com/questions/20170704/java-apache-poi-tab-stop-word-document

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!