Package org.apache.poi.xwpf.usermodel
Class XWPFHeaderFooter
java.lang.Object
org.apache.poi.ooxml.POIXMLDocumentPart
org.apache.poi.xwpf.usermodel.XWPFHeaderFooter
- All Implemented Interfaces:
IBody
- Direct Known Subclasses:
XWPFFooter,XWPFHeader
Parent of XWPF headers and footers
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPictureData(byte[] pictureData, int format) Adds a picture to the document.addPictureData(byte[] pictureData, PictureType pictureType) Adds a picture to the document.addPictureData(InputStream is, int format) Adds a picture to the document.addPictureData(InputStream is, PictureType pictureType) Adds a picture to the document.voidClears all paragraphs and tables from this header / footerAdds a new paragraph at the end of the header or footercreateTable(int rows, int cols) Adds a new table at the end of the header or footerget all Pictures in this packageReturns an Iterator with paragraphs and tables, in the order that they occur in the text.get a List of all ParagraphsgetOwner()getParagraph(CTP p) Returns the paragraph corresponding to the providedCTP.getParagraphArray(int pos) Returns the paragraph that holds the text of the header or footer.Returns the paragraph(s) that holds the text of the header or footer.getPart()returns the Part, to which the body belongs, which you need for adding relationship to other partsgetPictureDataByID(String blipID) returns the PictureData by blipIDgetTableArray(int pos) Returns the table at position posgetTableCell(CTTc cell) get the TableCell which belongs to the TableCellReturn the table(s) that holds the text of the header or footer, for complex cases where a paragraph isn't used.getText()Returns the textual content of the header/footer, by flattening out the text of its paragraph(s)Return XWPFDocumentinsertNewParagraph(XmlCursor cursor) add a new paragraph at position of the cursorinsertNewTbl(XmlCursor cursor) inserts a new Table at the cursor position.voidinsertTable(int pos, XWPFTable table) inserts an existing XWPFTable to the arrays bodyElements and tablesvoidvoidremoveParagraph(XWPFParagraph paragraph) Removes a specific paragraph from this header / footervoidremoveTable(XWPFTable table) Removes a specific table from this header / footervoidsetHeaderFooter(CTHdrFtr headerFooter) set a new headerFootervoidMethods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, isCommitted, setCommitted, toStringMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.poi.xwpf.usermodel.IBody
getPartType
-
Constructor Details
-
XWPFHeaderFooter
- Since:
- by POI 3.14-Beta1
-
-
Method Details
-
_getHdrFtr
-
getBodyElements
Description copied from interface:IBodyReturns an Iterator with paragraphs and tables, in the order that they occur in the text.- Specified by:
getBodyElementsin interfaceIBody
-
getParagraphs
Returns the paragraph(s) that holds the text of the header or footer. Normally there is only the one paragraph, but there could be more in certain cases, or a table.- Specified by:
getParagraphsin interfaceIBody
-
getTables
Return the table(s) that holds the text of the header or footer, for complex cases where a paragraph isn't used. Normally there's just one paragraph, but some complex headers/footers have a table or two in addition.- Specified by:
getTablesin interfaceIBody- Throws:
ArrayIndexOutOfBoundsException
-
getText
Returns the textual content of the header/footer, by flattening out the text of its paragraph(s) -
getTable
-
getParagraph
Description copied from interface:IBodyReturns the paragraph corresponding to the providedCTP.- Specified by:
getParagraphin interfaceIBody- Parameters:
p- is instance of CTP and is searching for an XWPFParagraph- Returns:
- The paragraph corresponding to the
CTP, ornullif there is no corresponding paragraph in this body.
-
getParagraphArray
Returns the paragraph that holds the text of the header or footer.- Specified by:
getParagraphArrayin interfaceIBody
-
getListParagraph
get a List of all Paragraphs- Returns:
- a list of
XWPFParagraph
-
getAllPictures
-
getAllPackagePictures
get all Pictures in this package- Returns:
- all Pictures in this package
-
addPictureData
Adds a picture to the document.- Parameters:
pictureData- The picture dataformat- The format of the picture.- Returns:
- the index to this picture (0 based), the added picture can be obtained from
getAllPictures(). - Throws:
InvalidFormatException- If the format of the picture is not known.- See Also:
-
addPictureData
public String addPictureData(byte[] pictureData, PictureType pictureType) throws InvalidFormatException Adds a picture to the document.- Parameters:
pictureData- The picture datapictureType- ThePictureTypeof the picture.- Returns:
- the index to this picture (0 based), the added picture can be obtained from
getAllPictures(). - Throws:
InvalidFormatException- If the format of the picture is not known.- Since:
- POI 5.2.3
-
addPictureData
Adds a picture to the document.- Parameters:
is- The stream to read image fromformat- The format of the picture.- Returns:
- the index to this picture (0 based), the added picture can be obtained from
getAllPictures(). - Throws:
InvalidFormatException- If the format of the picture is not known.IOException- If reading the picture-data from the stream fails.- See Also:
-
addPictureData
public String addPictureData(InputStream is, PictureType pictureType) throws InvalidFormatException, IOException Adds a picture to the document.- Parameters:
is- The stream to read image frompictureType- ThePictureTypeof the picture.- Returns:
- the index to this picture (0 based), the added picture can be obtained from
getAllPictures(). - Throws:
InvalidFormatException- If the format of the picture is not known.IOException- If reading the picture-data from the stream fails.- Since:
- POI 5.2.3
-
getPictureDataByID
returns the PictureData by blipID- Returns:
- XWPFPictureData of a specificID
-
createParagraph
Adds a new paragraph at the end of the header or footer- Returns:
- new
XWPFParagraphobject
-
createTable
Adds a new table at the end of the header or footer- Parameters:
rows- - number of rows in the tablecols- - number of columns in the table- Returns:
- new
XWPFTableobject
-
removeParagraph
Removes a specific paragraph from this header / footer- Parameters:
paragraph- -XWPFParagraphobject to remove
-
removeTable
Removes a specific table from this header / footer- Parameters:
table- -XWPFTableobject to remove
-
insertNewParagraph
add a new paragraph at position of the cursor- Specified by:
insertNewParagraphin interfaceIBody- Returns:
- the inserted paragraph
-
insertNewTbl
Description copied from interface:IBodyinserts a new Table at the cursor position.- Specified by:
insertNewTblin interfaceIBody- Returns:
- the inserted table
-
getOwner
-
getTableArray
Returns the table at position pos- Specified by:
getTableArrayin interfaceIBody
-
insertTable
inserts an existing XWPFTable to the arrays bodyElements and tables- Specified by:
insertTablein interfaceIBody
-
readHdrFtr
public void readHdrFtr() -
getTableCell
get the TableCell which belongs to the TableCell- Specified by:
getTableCellin interfaceIBody
-
getXWPFDocument
Description copied from interface:IBodyReturn XWPFDocument- Specified by:
getXWPFDocumentin interfaceIBody
-
setXWPFDocument
-
getPart
returns the Part, to which the body belongs, which you need for adding relationship to other parts
-