我正在尝试使用 Apache POI XSLF 库为 pptx 文件设置背景填充颜色。我的代码如下所示:
XSLFSlideMaster defaultMaster = ppt.getSlideMasters().get(0);
XSLFSlideLayout layout = defaultMaster.getLayout(SlideLayout.BLANK);
XSLFBackground background = layout.getBackground();
background.setFillColor(Color.BLACK);
这导致
Exception in thread "main" java.lang.IllegalStateException: CTShapeProperties was not found.
at org.apache.poi.xslf.usermodel.XSLFShape.getSpPr(XSLFShape.java:240)
at org.apache.poi.xslf.usermodel.XSLFSimpleShape.setFillColor(XSLFSimpleShape.java:549)
我试过在 SlideMaster 的背景、布局的背景和幻灯片的背景上调用它,都会导致相同的错误。