Package org.apache.poi.xssf.usermodel
Class XSSFDrawing
java.lang.Object
org.apache.poi.ooxml.POIXMLDocumentPart
org.apache.poi.xssf.usermodel.XSSFDrawing
Represents a SpreadsheetML drawing
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Create a new SpreadsheetML drawingXSSFDrawing
(PackagePart part) Construct a SpreadsheetML drawing from a package part -
Method Summary
Modifier and TypeMethodDescriptionprotected PackageRelationship
addPictureReference
(int pictureIndex) Add the indexed picture to this drawing relationsprotected void
commit()
Save the content in the underlying package part.createAnchor
(int dx1, int dy1, int dx2, int dy2, int col1, int row1, int col2, int row2) Creates a new client anchor and sets the top-left and bottom-right coordinates of the anchor.createCellComment
(ClientAnchor anchor) Creates a comment.createChart
(ClientAnchor anchor) Creates a chart.createChart
(XSSFClientAnchor anchor) Creates a chart.createConnector
(XSSFClientAnchor anchor) Creates a simple shape.createGroup
(XSSFClientAnchor anchor) Creates a simple shape.createObjectData
(ClientAnchor anchor, int storageId, int pictureIndex) Adds a new OLE Package ShapecreatePicture
(ClientAnchor anchor, int pictureIndex) Creates a picture.createPicture
(XSSFClientAnchor anchor, int pictureIndex) Creates a picture.createSimpleShape
(XSSFClientAnchor anchor) Creates a simple shape.createTextbox
(XSSFClientAnchor anchor) Constructs a textbox under the drawing.Returns all charts in this drawing.org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing
Return the underlying CTDrawing bean, the root element of the SpreadsheetML Drawing part.getShapes
(XSSFShapeGroup groupshape) getSheet()
importChart
(XSSFChart srcChart) Imports the chart from thesrcChart
into this drawing.iterator()
Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommited, onDocumentCreate, onDocumentRead, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, removeRelation, setCommited, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
NAMESPACE_A
- See Also:
-
NAMESPACE_C
- See Also:
-
-
Constructor Details
-
XSSFDrawing
protected XSSFDrawing()Create a new SpreadsheetML drawing- See Also:
-
XSSFDrawing
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:
IOException
org.apache.xmlbeans.XmlException
- Since:
- POI 3.14-Beta1
-
-
Method Details
-
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
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(); OutputStream out = part.getOutputStream(); XmlObject bean = getXmlBean(); //the "model" which holds changes in memory bean.save(out, DEFAULT_XML_OPTIONS); out.close(); }
- Overrides:
commit
in 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) Description copied from interface:Drawing
Creates a new client anchor and sets the top-left and bottom-right coordinates of the anchor.- Specified by:
createAnchor
in interfaceDrawing<XSSFShape>
- Parameters:
dx1
- the x coordinate in EMU within the first cell.dy1
- the y coordinate in EMU within the first cell.dx2
- the x coordinate in EMU within the second cell.dy2
- the y coordinate in EMU within the second cell.col1
- the column (0 based) of the first cell.row1
- the row (0 based) of the first cell.col2
- the column (0 based) of the second cell.row2
- the row (0 based) of the second cell.- Returns:
- the newly created client anchor
-
createTextbox
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
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
Description copied from interface:Drawing
Creates a picture.- Specified by:
createPicture
in interfaceDrawing<XSSFShape>
- 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.- Returns:
- the newly created picture.
-
createChart
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
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) throws IOException, org.apache.xmlbeans.XmlException Imports the chart from thesrcChart
into this drawing.- Parameters:
srcChart
- the source chart to be cloned into this drawing.- Returns:
- the newly created chart.
- Throws:
org.apache.xmlbeans.XmlException
IOException
- Since:
- 4.0.0
-
addPictureReference
Add the indexed picture to this drawing relations- Parameters:
pictureIndex
- the index of the picture in the workbook collection of pictures,XSSFWorkbook.getAllPictures()
.
-
createSimpleShape
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
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
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
Creates a comment.- Specified by:
createCellComment
in interfaceDrawing<XSSFShape>
- Parameters:
anchor
- the client anchor describes how this comment is attached to the sheet.- Returns:
- the newly created comment.
-
createObjectData
Description copied from interface:Drawing
Adds a new OLE Package Shape- Specified by:
createObjectData
in interfaceDrawing<XSSFShape>
- Parameters:
anchor
- the client anchor describes how this picture is attached to the sheet.storageId
- the storageId returned byWorkbook.addOlePackage(byte[], String, String, String)
pictureIndex
- the index of the picture (used as preview image) in the workbook collection of pictures.- Returns:
- newly created shape
-
getCharts
Returns all charts in this drawing. -
getShapes
- Returns:
- list of shapes in this drawing
-
getShapes
- Returns:
- list of shapes in this shape group
-
iterator
-
getSheet
- Returns:
- the sheet associated with the drawing
-