没错,您需要w:bottomFromText,例如:
<w:tbl>
<w:tblPr>
<w:tblpPr w:leftFromText="187" w:rightFromText="187" w:bottomFromText="4320" w:vertAnchor="text" w:tblpY="1"/>
<w:tblOverlap w:val="never"/>
</w:tblPr>
基于以上所述,您的代码看起来是合理的。
作为比较,如果您使用docx4j进行操作,您可以通过以下两种方式之一创建它。
第一种方法是显式使用 JAXB 对象工厂:
org.docx4j.wml.ObjectFactory wmlObjectFactory = new org.docx4j.wml.ObjectFactory();
Tbl tbl = wmlObjectFactory.createTbl();
JAXBElement<org.docx4j.wml.Tbl> tblWrapped = wmlObjectFactory.createBodyTbl(tbl);
// Create object for tblPr
TblPr tblpr = wmlObjectFactory.createTblPr();
tbl.setTblPr(tblpr);
// Create object for tblpPr
CTTblPPr tblppr = wmlObjectFactory.createCTTblPPr();
tblpr.setTblpPr(tblppr);
tblppr.setLeftFromText( BigInteger.valueOf( 187) );
tblppr.setRightFromText( BigInteger.valueOf( 187) );
tblppr.setBottomFromText( BigInteger.valueOf( 4320) );
tblppr.setVertAnchor(org.docx4j.wml.STVAnchor.TEXT);
tblppr.setTblpY( BigInteger.valueOf( 1) );
// Create object for tblOverlap
CTTblOverlap tbloverlap = wmlObjectFactory.createCTTblOverlap();
tblpr.setTblOverlap(tbloverlap);
tbloverlap.setVal(org.docx4j.wml.STTblOverlap.NEVER);
第二个是解组一个字符串:
String openXML = "<w:tbl xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">
+ "<w:tblPr>
+ "<w:tblpPr w:bottomFromText=\"4320\" w:leftFromText=\"187\" w:rightFromText=\"187\" w:tblpY=\"1\" w:vertAnchor=\"text\"/>"
+ "<w:tblOverlap w:val=\"never\"/>"
+"</w:tblPr>"
etc
+"</w:tbl>";
Tbl tbl = (Tbl)XmlUtils.unmarshalString(openXML);