CTSectPr sectPr = document.getDocument().getBody().addNewSectPr(); CTPageMar pageMar = sectPr.addNewPgMar(); pageMar.setLeft(BigInteger.valueOf(720L)); pageMar.setTop(BigInteger.valueOf(1440L)); pageMar.setRight(BigInteger.valueOf(720L)); pageMar.setBottom(BigInteger.valueOf(1440L))
在导入org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPageMar类的时候可能找不到引用的jar包,提示“The type org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPageMar cannot be resolved”
下载ooxml-schemas 1.1 http://repo.maven.apache.org/maven2/org/apache/poi/ooxml-schemas/1.1/
POI 3.8、POI3.9、POI3.10.1和POI 3.11的jar包中都不包含CTPageMar这个类
其他常用的一些样式设置可以参考http://53873039oycg.iteye.com/blog/2153194