Package org.apache.poi.xssf.model
Class CommentsTable
- java.lang.Object
-
- org.apache.poi.ooxml.POIXMLDocumentPart
-
- org.apache.poi.xssf.model.CommentsTable
-
- All Implemented Interfaces:
Comments
@Internal public class CommentsTable extends POIXMLDocumentPart implements Comments
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_AUTHORstatic intDEFAULT_AUTHOR_ID
-
Constructor Summary
Constructors Constructor Description CommentsTable()CommentsTable(PackagePart part)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcommentUpdated(XSSFComment comment)Called after the comment is updated, so that we can reflect that in our cacheprotected voidcommit()Save the content in the underlying package part.XSSFCommentcreateNewComment(ClientAnchor clientAnchor)Create a new comment and add to the CommentTable.intfindAuthor(String author)XSSFCommentfindCellComment(CellAddress cellAddress)Finds the cell comment at cellAddress, if one existsStringgetAuthor(long authorId)Iterator<CellAddress>getCellAddresses()Returns all cell addresses that have comments.org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCommentsgetCTComments()Returns the underlying CTComments list xmlbeanintgetNumberOfAuthors()intgetNumberOfComments()org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCommentnewComment(CellAddress ref)Create a new comment located at cell addressvoidreadFrom(InputStream is)voidreferenceUpdated(CellAddress oldReference, XSSFComment comment)Called after the reference is updated, so that we can reflect that in our cachevoidreferenceUpdated(CellAddress oldReference, org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment comment)Deprecated.booleanremoveComment(CellAddress cellRef)Remove the comment at cellRef location, if one existsvoidsetSheet(Sheet sheet)This method is for internal POI use only.voidwriteTo(OutputStream out)-
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
-
DEFAULT_AUTHOR
public static final String DEFAULT_AUTHOR
- See Also:
- Constant Field Values
-
DEFAULT_AUTHOR_ID
public static final int DEFAULT_AUTHOR_ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CommentsTable
public CommentsTable()
-
CommentsTable
public CommentsTable(PackagePart part) throws IOException
- Throws:
IOException- Since:
- POI 3.14-Beta1
-
-
Method Detail
-
readFrom
public void readFrom(InputStream is) throws IOException
- Throws:
IOException
-
writeTo
public void writeTo(OutputStream out) throws IOException
- Throws:
IOException
-
setSheet
@Internal public void setSheet(Sheet sheet)
Description copied from interface:CommentsThis method is for internal POI use only. POI uses it to link the sheet and comments table. This method will not move comments from one sheet to another (if a user tries to use this method for that purpose).
-
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
-
referenceUpdated
@Deprecated @Removal(version="6.0.0") public void referenceUpdated(CellAddress oldReference, org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment comment)
Deprecated.Called after the reference is updated, so that we can reflect that in our cache- Parameters:
oldReference- the comment to remove from the commentRefs mapcomment- the comment to replace in the commentRefs map
-
referenceUpdated
public void referenceUpdated(CellAddress oldReference, XSSFComment comment)
Called after the reference is updated, so that we can reflect that in our cache- Specified by:
referenceUpdatedin interfaceComments- Parameters:
oldReference- the comment to remove from the commentRefs mapcomment- the comment to replace in the commentRefs map- Since:
- POI 5.2.0
- See Also:
commentUpdated(XSSFComment)
-
commentUpdated
public void commentUpdated(XSSFComment comment)
Called after the comment is updated, so that we can reflect that in our cache- Specified by:
commentUpdatedin interfaceComments- Parameters:
comment- the comment to replace in the commentRefs map- Since:
- POI 5.2.0
- See Also:
referenceUpdated(CellAddress, XSSFComment)
-
getNumberOfComments
public int getNumberOfComments()
- Specified by:
getNumberOfCommentsin interfaceComments
-
getNumberOfAuthors
public int getNumberOfAuthors()
- Specified by:
getNumberOfAuthorsin interfaceComments
-
findAuthor
public int findAuthor(String author)
- Specified by:
findAuthorin interfaceComments
-
findCellComment
public XSSFComment findCellComment(CellAddress cellAddress)
Finds the cell comment at cellAddress, if one exists- Specified by:
findCellCommentin interfaceComments- Parameters:
cellAddress- the address of the cell to find a comment- Returns:
- cell comment if one exists, otherwise returns null
-
getCellAddresses
public Iterator<CellAddress> getCellAddresses()
Returns all cell addresses that have comments.- Specified by:
getCellAddressesin interfaceComments- Returns:
- An iterator to traverse all cell addresses that have comments.
- Since:
- 4.0.0
-
createNewComment
public XSSFComment createNewComment(ClientAnchor clientAnchor)
Create a new comment and add to the CommentTable.- Specified by:
createNewCommentin interfaceComments- Parameters:
clientAnchor- the anchor for this comment- Returns:
- new XSSFComment
- Since:
- POI 5.2.0
-
newComment
@Internal public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment newComment(CellAddress ref)
Create a new comment located at cell address- Parameters:
ref- the location to add the comment- Returns:
- a new CTComment located at ref with default author
-
removeComment
public boolean removeComment(CellAddress cellRef)
Remove the comment at cellRef location, if one exists- Specified by:
removeCommentin interfaceComments- Parameters:
cellRef- the location of the comment to remove- Returns:
- returns true if a comment was removed
-
getCTComments
@Internal public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments getCTComments()
Returns the underlying CTComments list xmlbean- Returns:
- underlying comments list xmlbean
-
-