其他分享
首页 > 其他分享> > 解决 POI word 设置页边距 找不到类

解决 POI word 设置页边距 找不到类

作者:互联网

XWPFDocument document= new XWPFDocument();
CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
 CTPageMar pageMar = sectPr.addNewPgMar();
  pageMar.setTop(BigInteger.valueOf(720L));
   pageMar.setBottom(BigInteger.valueOf(720L));
   pageMar.setLeft(BigInteger.valueOf(1440L));
   pageMar.setRight(BigInteger.valueOf(1440L));

注意  新版本的POI需要引入ooxml-schemas-1.1.jar

Exception in thread "main" java.lang.NoClassDefFoundError: org/openxmlformats/schemas/wordprocessingml/x2006/main/CTPageMar
    at org.openxmlformats.schemas.wordprocessingml.x2006.main.impl.CTSectPrImpl.addNewPgMar(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPageMar
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 2 more

 

标签:lang,BigInteger,java,valueOf,pageMar,设置,POI,word,schemas
来源: https://blog.csdn.net/luckhappystar/article/details/119218271