POI设置Word页边距

参考资料:http://stackoverflow.com/questions/17787176/spacing-and-margin-settings-in-word-document-using-apache-poi-docx

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

解决办法参考http://stackoverflow.com/questions/10208097/how-to-copy-a-paragraph-of-docx-to-another-docx-withjava-and-retain-the-style

下载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

原文地址:https://www.cnblogs.com/wenlong/p/4524966.html