Package org.apache.poi.xssf.usermodel
Class XSSFDrawing
- java.lang.Object
-
- org.apache.poi.ooxml.POIXMLDocumentPart
-
- org.apache.poi.xssf.usermodel.XSSFDrawing
-
public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing<XSSFShape>
Represents a SpreadsheetML drawing
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringNAMESPACE_Aprotected static StringNAMESPACE_C
-
Constructor Summary
Constructors Modifier Constructor Description protectedXSSFDrawing()Create a new SpreadsheetML drawingXSSFDrawing(PackagePart part)Construct a SpreadsheetML drawing from a package part
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected PackageRelationshipaddPictureReference(int pictureIndex)Add the indexed picture to this drawing relationsprotected voidcommit()Save the content in the underlying package part.XSSFClientAnchorcreateAnchor(int dx1, int dy1, int dx2, int dy2, int col1, int row1, int col2, int row2)XSSFCommentcreateCellComment(ClientAnchor anchor)Creates a comment.XSSFChartcreateChart(ClientAnchor anchor)Creates a chart.XSSFChartcreateChart(XSSFClientAnchor anchor)Creates a chart.protected POIXMLDocumentPart.RelationPartcreateChartRelationPart()XSSFConnectorcreateConnector(XSSFClientAnchor anchor)Creates a simple shape.XSSFShapeGroupcreateGroup(XSSFClientAnchor anchor)Creates a simple shape.XSSFObjectDatacreateObjectData(ClientAnchor anchor, int storageId, int pictureIndex)XSSFPicturecreatePicture(ClientAnchor anchor, int pictureIndex)XSSFPicturecreatePicture(XSSFClientAnchor anchor, int pictureIndex)Creates a picture.XSSFSimpleShapecreateSimpleShape(XSSFClientAnchor anchor)Creates a simple shape.XSSFTextBoxcreateTextbox(XSSFClientAnchor anchor)Constructs a textbox under the drawing.List<XSSFChart>getCharts()Returns all charts in this drawing.org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawinggetCTDrawing()Return the underlying CTDrawing bean, the root element of the SpreadsheetML Drawing part.List<XSSFShape>getShapes()List<XSSFShape>getShapes(XSSFShapeGroup groupshape)XSSFSheetgetSheet()XSSFChartimportChart(XSSFChart srcChart)Imports the chart from thesrcChartinto this drawing.Iterator<XSSFShape>iterator()Spliterator<XSSFShape>spliterator()-
Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRead, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, removeRelation, setCommitted, toString
-
-
-
-
Field Detail
-
NAMESPACE_A
protected static final String NAMESPACE_A
- See Also:
- Constant Field Values
-
NAMESPACE_C
protected static final String NAMESPACE_C
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XSSFDrawing
protected XSSFDrawing()
Create a new SpreadsheetML drawing- See Also:
XSSFSheet.createDrawingPatriarch()
-
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 beapplication/vnd.openxmlformats-officedocument.drawing+xml- Throws:
IOExceptionXmlException- 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 IOExceptionDescription copied from class:POIXMLDocumentPartSave 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:
commitin classPOIXMLDocumentPart- Throws:
IOException- a subclass may throw an IOException if the changes can't be committed
-
createAnchor
public XSSFClientAnchor createAnchor(int dx1, int dy1, int dx2, int dy2, int col1, int row1, int col2, int row2)
- Specified by:
createAnchorin interfaceDrawing<XSSFShape>
-
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.
-
createPicture
public XSSFPicture createPicture(ClientAnchor anchor, int pictureIndex)
- Specified by:
createPicturein interfaceDrawing<XSSFShape>
-
createChart
public XSSFChart createChart(XSSFClientAnchor anchor)
Creates a chart.- Parameters:
anchor- the client anchor describes how this chart is attached to the sheet.- Returns:
- the newly created chart
- See Also:
createChart(ClientAnchor)
-
createChartRelationPart
protected POIXMLDocumentPart.RelationPart createChartRelationPart()
-
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 thesrcChartinto 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:
createCellCommentin interfaceDrawing<XSSFShape>- Parameters:
anchor- the client anchor describes how this comment is attached to the sheet.- Returns:
- the newly created comment.
-
createObjectData
public XSSFObjectData createObjectData(ClientAnchor anchor, int storageId, int pictureIndex)
- Specified by:
createObjectDatain interfaceDrawing<XSSFShape>
-
getShapes
public List<XSSFShape> getShapes(XSSFShapeGroup groupshape)
- Returns:
- list of shapes in this shape group
-
spliterator
public Spliterator<XSSFShape> spliterator()
- Specified by:
spliteratorin interfaceIterable<XSSFShape>- Since:
- POI 5.2.0
-
getSheet
public XSSFSheet getSheet()
- Returns:
- the sheet associated with the drawing
-
-