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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM