I'm trying to set the background fill color for a pptx file using the Apache POI XSLF library. My code looks like this:
XSLFSlideMaster defaultMaster = ppt.getSlideMasters().get(0);
XSLFSlideLayout layout = defaultMaster.getLayout(SlideLayout.BLANK);
XSLFBackground background = layout.getBackground();
background.setFillColor(Color.BLACK);
which results in
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)
I've tried calling this on SlideMaster's background, the layout's background, and the slide's background and all result in the same error.
This was fixed in POI 3.15-beta2 via #59702.
The "problem" with the OOXml properties or the POI implementation or the xmlbeans schemas is, that similar attributes like colors are stored below different schema types and the old code didn't cover that parent nodes. The patch introduced delegates to wrap those differences and the XSLF usermodel methods can be now more uniform.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With