Class XSSFDrawing

    • Constructor Detail

      • XSSFDrawing

        public XSSFDrawing​(PackagePart part)
                    throws IOException,
                           XmlException
        Construct a SpreadsheetML drawing from a package part
        Parameters:
        part - the package part holding the drawing data, the content type must be application/vnd.openxmlformats-officedocument.drawing+xml
        Throws:
        IOException
        XmlException
        Since:
        POI 3.14-Beta1
    • Method Detail

      • getCTDrawing

        @Internal
        public org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing getCTDrawing()
        Return the underlying CTDrawing bean, the root element of the SpreadsheetML Drawing part.
        Returns:
        the underlying CTDrawing bean
      • commit

        protected void commit()
                       throws IOException
        Description copied from class: POIXMLDocumentPart
        Save the content in the underlying package part. Default implementation is empty meaning that the package part is left unmodified.

        Sub-classes should override and add logic to marshal the "model" into Ooxml4J.

        For example, the code saving a generic XML entry may look as follows:

         protected void commit() throws IOException {
           PackagePart part = getPackagePart();
           try (OutputStream out = part.getOutputStream()) {
             XmlObject bean = getXmlBean(); //the "model" which holds changes in memory
             bean.save(out, DEFAULT_XML_OPTIONS);
           }
         }
         
        Overrides:
        commit in class POIXMLDocumentPart
        Throws:
        IOException - a subclass may throw an IOException if the changes can't be committed
      • createTextbox

        public XSSFTextBox createTextbox​(XSSFClientAnchor anchor)
        Constructs a textbox under the drawing.
        Parameters:
        anchor - the client anchor describes how this group is attached to the sheet.
        Returns:
        the newly created textbox.
      • createPicture

        public XSSFPicture createPicture​(XSSFClientAnchor anchor,
                                         int pictureIndex)
        Creates a picture.
        Parameters:
        anchor - the client anchor describes how this picture is attached to the sheet.
        pictureIndex - the index of the picture in the workbook collection of pictures, XSSFWorkbook.getAllPictures() .
        Returns:
        the newly created picture shape.
      • createChart

        public XSSFChart createChart​(ClientAnchor anchor)
        Creates a chart.
        Parameters:
        anchor - the client anchor describes how this chart is attached to the sheet.
        Returns:
        the newly created chart
      • importChart

        public XSSFChart importChart​(XSSFChart srcChart)
        Imports the chart from the srcChart into this drawing.
        Parameters:
        srcChart - the source chart to be cloned into this drawing.
        Returns:
        the newly created chart.
        Since:
        4.0.0
      • addPictureReference

        protected PackageRelationship addPictureReference​(int pictureIndex)
        Add the indexed picture to this drawing relations
        Parameters:
        pictureIndex - the index of the picture in the workbook collection of pictures, XSSFWorkbook.getAllPictures() .
      • createSimpleShape

        public XSSFSimpleShape createSimpleShape​(XSSFClientAnchor anchor)
        Creates a simple shape. This includes such shapes as lines, rectangles, and ovals.
        Parameters:
        anchor - the client anchor describes how this group is attached to the sheet.
        Returns:
        the newly created shape.
      • createConnector

        public XSSFConnector createConnector​(XSSFClientAnchor anchor)
        Creates a simple shape. This includes such shapes as lines, rectangles, and ovals.
        Parameters:
        anchor - the client anchor describes how this group is attached to the sheet.
        Returns:
        the newly created shape.
      • createGroup

        public XSSFShapeGroup createGroup​(XSSFClientAnchor anchor)
        Creates a simple shape. This includes such shapes as lines, rectangles, and ovals.
        Parameters:
        anchor - the client anchor describes how this group is attached to the sheet.
        Returns:
        the newly created shape.
      • createCellComment

        public XSSFComment createCellComment​(ClientAnchor anchor)
        Creates a comment.
        Specified by:
        createCellComment in interface Drawing<XSSFShape>
        Parameters:
        anchor - the client anchor describes how this comment is attached to the sheet.
        Returns:
        the newly created comment.
      • getCharts

        public List<XSSFChart> getCharts()
        Returns all charts in this drawing.
      • getShapes

        public List<XSSFShape> getShapes()
        Returns:
        list of shapes in this drawing
      • getSheet

        public XSSFSheet getSheet()
        Returns:
        the sheet associated with the drawing