Java的Apache的POI制表位的Word文档 [英] Java Apache POI Tab Stop word document

查看:798
本文介绍了Java的Apache的POI制表位的Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有了类似如下的word文档
一个名称(左对齐)和价格(排列一路右侧)都在同一行。我相信这是由制表位在Word文档中完成的。这里是一个例子,见的第一行。

是否有可能为我打印出来到Word文档中,像第一个行?我检查的Apache POI的文档左右,但什么也没有看见,允许您设置制表位。但是,我不知道是否有另一种方式来获得的第一线像她那样。

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.

推荐答案

我用这个方法来添加标签停止

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);
}

这篇关于Java的Apache的POI制表位的Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆