Package org.apache.poi.xslf.usermodel
Class XSLFSheet
- java.lang.Object
-
- org.apache.poi.ooxml.POIXMLDocumentPart
-
- org.apache.poi.xslf.usermodel.XSLFSheet
-
- All Implemented Interfaces:
Iterable<XSLFShape>,ShapeContainer<XSLFShape,XSLFTextParagraph>,Sheet<XSLFShape,XSLFTextParagraph>,XSLFShapeContainer
- Direct Known Subclasses:
XSLFNotes,XSLFNotesMaster,XSLFSlide,XSLFSlideLayout,XSLFSlideMaster
@Beta public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeContainer, Sheet<XSLFShape,XSLFTextParagraph>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedXSLFSheet()protectedXSLFSheet(PackagePart part)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddChart(XSLFChart chart)this method will add chart into slide with default height, width, x and yvoidaddChart(XSLFChart chart, Rectangle2D rect2D)this method will add chart into slide with given height, width, x and yvoidaddShape(XSLFShape shape)protected intallocateShapeId()XSLFSheetappendContent(XSLFSheet src)Append content to this sheet.protected static List<XSLFShape>buildShapes(org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape spTree, XSLFShapeContainer parent)voidclear()Removes all of the elements from this container (optional operation).protected voidcommit()Save the content in the underlying package part.XSLFAutoShapecreateAutoShape()XSLFConnectorShapecreateConnector()XSLFFreeformShapecreateFreeform()XSLFGroupShapecreateGroup()XSLFObjectShapecreateOleShape(PictureData pictureData)XSLFPictureShapecreatePicture(PictureData pictureData)XSLFTablecreateTable()XSLFTablecreateTable(int numRows, int numCols)XSLFTextBoxcreateTextBox()protected voidderegisterShapeId(int shapeId)voiddraw(Graphics2D graphics)Render this sheet into the supplied graphics objectXSLFBackgroundgetBackground()booleangetFollowMasterGraphics()XSLFTextShapegetPlaceholder(int idx)XSLFSimpleShapegetPlaceholder(Placeholder ph)XSLFSimpleShapegetPlaceholder(org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder ph)XSLFPlaceholderDetailsgetPlaceholderDetails(Placeholder placeholder)XSLFTextShape[]getPlaceholders()protected abstract StringgetRootElementName()List<XSLFShape>getShapes()Returns an array containing all of the shapes in this sheetXMLSlideShowgetSlideShow()protected org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapegetSpTree()protected XSLFTextShapegetTextShapeByType(Placeholder type)XSLFThemegetTheme()abstract XmlObjectgetXmlObject()XSLFSheetimportContent(XSLFSheet src)Set the contents of this sheet to be a copy of the source sheet.Iterator<XSLFShape>iterator()Returns an iterator over the shapes in this sheetprotected StringmapSchemeColor(org.openxmlformats.schemas.drawingml.x2006.main.CTColorMappingOverride cmapOver, String schemeColor)protected StringmapSchemeColor(org.openxmlformats.schemas.drawingml.x2006.main.CTColorMapping cmap, String schemeColor)protected voidregisterShapeId(int shapeId)booleanremoveShape(XSLFShape xShape)Removes the specified shape from this sheet, if it is present (optional operation).-
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
-
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
-
Methods inherited from interface org.apache.poi.sl.usermodel.Sheet
getMasterSheet
-
-
-
-
Constructor Detail
-
XSLFSheet
protected XSLFSheet()
-
XSLFSheet
protected XSLFSheet(PackagePart part)
- Since:
- POI 3.14-Beta1
-
-
Method Detail
-
getSlideShow
public XMLSlideShow getSlideShow()
- Specified by:
getSlideShowin interfaceSheet<XSLFShape,XSLFTextParagraph>- Returns:
- the XMLSlideShow this sheet belongs to
-
allocateShapeId
protected int allocateShapeId()
-
registerShapeId
protected void registerShapeId(int shapeId)
-
deregisterShapeId
protected void deregisterShapeId(int shapeId)
-
buildShapes
protected static List<XSLFShape> buildShapes(org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape spTree, XSLFShapeContainer parent)
-
getXmlObject
public abstract XmlObject getXmlObject()
- Returns:
- top-level Xml bean representing this sheet
-
getShapes
public List<XSLFShape> getShapes()
Returns an array containing all of the shapes in this sheet- Specified by:
getShapesin interfaceShapeContainer<XSLFShape,XSLFTextParagraph>- Returns:
- an array of all shapes in this sheet
-
createAutoShape
public XSLFAutoShape createAutoShape()
- Specified by:
createAutoShapein interfaceShapeContainer<XSLFShape,XSLFTextParagraph>- Specified by:
createAutoShapein interfaceXSLFShapeContainer
-
createFreeform
public XSLFFreeformShape createFreeform()
- Specified by:
createFreeformin interfaceShapeContainer<XSLFShape,XSLFTextParagraph>- Specified by:
createFreeformin interfaceXSLFShapeContainer
-
createTextBox
public XSLFTextBox createTextBox()
- Specified by:
createTextBoxin interfaceShapeContainer<XSLFShape,XSLFTextParagraph>- Specified by:
createTextBoxin interfaceXSLFShapeContainer
-
createConnector
public XSLFConnectorShape createConnector()
- Specified by:
createConnectorin interfaceShapeContainer<XSLFShape,XSLFTextParagraph>- Specified by:
createConnectorin interfaceXSLFShapeContainer
-
createGroup
public XSLFGroupShape createGroup()
- Specified by:
createGroupin interfaceShapeContainer<XSLFShape,XSLFTextParagraph>- Specified by:
createGroupin interfaceXSLFShapeContainer
-
createPicture
public XSLFPictureShape createPicture(PictureData pictureData)
- Specified by:
createPicturein interfaceShapeContainer<XSLFShape,XSLFTextParagraph>- Specified by:
createPicturein interfaceXSLFShapeContainer
-
createTable
public XSLFTable createTable()
-
createTable
public XSLFTable createTable(int numRows, int numCols)
- Specified by:
createTablein interfaceShapeContainer<XSLFShape,XSLFTextParagraph>
-
createOleShape
public XSLFObjectShape createOleShape(PictureData pictureData)
- Specified by:
createOleShapein interfaceShapeContainer<XSLFShape,XSLFTextParagraph>
-
addShape
public void addShape(XSLFShape shape)
- Specified by:
addShapein interfaceShapeContainer<XSLFShape,XSLFTextParagraph>
-
removeShape
public boolean removeShape(XSLFShape xShape)
Removes the specified shape from this sheet, if it is present (optional operation). If this sheet does not contain the element, it is unchanged.- Specified by:
removeShapein interfaceShapeContainer<XSLFShape,XSLFTextParagraph>- Parameters:
xShape- shape to be removed from this sheet, if present- Returns:
trueif this sheet contained the specified element- Throws:
IllegalArgumentException- if the type of the specified shape is incompatible with this sheet (optional)
-
clear
public void clear()
Removes all of the elements from this container (optional operation). The container will be empty after this call returns.- Specified by:
clearin interfaceXSLFShapeContainer
-
getRootElementName
protected abstract String getRootElementName()
-
getSpTree
protected org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape getSpTree()
-
commit
protected final 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
-
importContent
public XSLFSheet importContent(XSLFSheet src)
Set the contents of this sheet to be a copy of the source sheet. This method erases any existing shapes and replaces them with object from the source sheet.- Parameters:
src- the source sheet to copy data from- Returns:
- modified 'this'
-
appendContent
public XSLFSheet appendContent(XSLFSheet src)
Append content to this sheet.- Parameters:
src- the source sheet- Returns:
- modified
this.
-
getTheme
public XSLFTheme getTheme()
- Returns:
- theme (shared styles) associated with this theme.
By default returns
nullwhich means that this sheet is theme-less. Sheets that support the notion of themes (slides, masters, layouts, etc.) should override this method and return the corresponding package part.
-
getTextShapeByType
protected XSLFTextShape getTextShapeByType(Placeholder type)
-
getPlaceholder
public XSLFSimpleShape getPlaceholder(Placeholder ph)
-
getPlaceholder
@Internal public XSLFSimpleShape getPlaceholder(org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder ph)
-
getPlaceholder
public XSLFTextShape getPlaceholder(int idx)
- Parameters:
idx- 0-based index of a placeholder in the sheet- Returns:
- placeholder
-
getPlaceholders
public XSLFTextShape[] getPlaceholders()
- Returns:
- all placeholder shapes in this sheet
-
getFollowMasterGraphics
public boolean getFollowMasterGraphics()
- Specified by:
getFollowMasterGraphicsin interfaceSheet<XSLFShape,XSLFTextParagraph>- Returns:
- whether shapes on the master sheet should be shown. By default master graphics is turned off. Sheets that support the notion of master (slide, slideLayout) should override it and check this setting in the sheet XML
-
getBackground
public XSLFBackground getBackground()
- Specified by:
getBackgroundin interfaceSheet<XSLFShape,XSLFTextParagraph>- Returns:
- background for this sheet
-
draw
public void draw(Graphics2D graphics)
Render this sheet into the supplied graphics object- Specified by:
drawin interfaceSheet<XSLFShape,XSLFTextParagraph>- Parameters:
graphics- the graphics context to draw to
-
getPlaceholderDetails
public XSLFPlaceholderDetails getPlaceholderDetails(Placeholder placeholder)
- Specified by:
getPlaceholderDetailsin interfaceSheet<XSLFShape,XSLFTextParagraph>
-
addChart
public void addChart(XSLFChart chart)
this method will add chart into slide with default height, width, x and y- Parameters:
chart- xslf chart object- Since:
- POI 4.1.0
-
addChart
public void addChart(XSLFChart chart, Rectangle2D rect2D)
this method will add chart into slide with given height, width, x and y- Parameters:
chart- xslf chart object- Since:
- POI 4.1.0
-
mapSchemeColor
protected String mapSchemeColor(org.openxmlformats.schemas.drawingml.x2006.main.CTColorMappingOverride cmapOver, String schemeColor)
-
-