Class XSLFDiagram

  • All Implemented Interfaces:
    GraphicalFrame<XSLFShape,​XSLFTextParagraph>, PlaceableShape<XSLFShape,​XSLFTextParagraph>, Shape<XSLFShape,​XSLFTextParagraph>

    @Beta
    public class XSLFDiagram
    extends XSLFGraphicFrame
    Representation of a DrawingML Diagram

    This class converts the diagram to an XSLFGroupShape accessible via getGroupShape(). The underlying XSLFDiagramDrawing used to create the group shape is accessible via getDiagramDrawing().

    In pptx files, these diagrams are generated by creating SmartArt. When a pptx has SmartArt, a directory with the following structure is created:

     ppt/
       diagrams/
         data#.xml
         drawing#.xml^
         colors#.xml
         quickStyle#.xml
         layout#.xml
         rels/
           data#.xml.rels
           drawing#.xml.rels
     

    ^The `drawing#.xml` file is not in the OpenXML spec. It was added as an extension by Microsoft, namespace: http://schemas.microsoft.com/office/drawing/2008/diagram

    The drawing#.xml file contains the rendered output of the diagram. This class reads the underlying drawing#.xml and converts it to a XSLFGroupShape.

    The data, drawing, colors, and quickStyle files are in the OpenXML spec. These contain the instructions that define how to render the diagram. Rendering diagrams from these files is not trivial, they support for loops, if/elses, etc. Integrating such a change into POI would be quite sophisticated and challenging.

    Since:
    POI 5.2.3
    • Field Detail

      • DRAWINGML_DIAGRAM_URI

        public static final java.lang.String DRAWINGML_DIAGRAM_URI
        See Also:
        Constant Field Values
    • Method Detail

      • getGroupShape

        public org.apache.poi.xslf.usermodel.XSLFDiagram.XSLFDiagramGroupShape getGroupShape()
        Returns the diagram represented as a grouped shape.