Java Apache POI Tab 停用词文档 [英] Java Apache POI Tab Stop word document

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

问题描述

我有一个 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 Tab 停用词文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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