Class XSSFHeaderFooter
java.lang.Object
org.apache.poi.xssf.usermodel.extensions.XSSFHeaderFooter
- All Implemented Interfaces:
HeaderFooter
- Direct Known Subclasses:
XSSFEvenFooter
,XSSFEvenHeader
,XSSFFirstFooter
,XSSFFirstHeader
,XSSFOddFooter
,XSSFOddHeader
Parent class of all XSSF headers and footers.
For a list of all the different fields that can be placed into a header or
footer, such as page number, bold, underline etc, see the follow formatting
syntax
Header/Footer Formatting Syntax
There are a number of formatting codes that can be written inline with the actual header / footer text, which affect the formatting in the header or footer.
This example shows the text "Center Bold Header" on the first line (center section), and the date on the second line (center section). invalid input: '&CCenter' invalid input: '&'"-,Bold"Bold invalid input: '&'"-,Regular"Header_x000A_invalid input: '&D' General Rules: There is no required order in which these codes must appear. The first occurrence of the following codes turns the formatting ON, the second occurrence turns it OFF again:- invalid input: '&L'
- code for "left section" (there are three header / footer locations, "left", "center", and "right"). When two or more occurrences of this section marker exist, the contents from all markers are concatenated, in the order of appearance, and placed into the left section.
- invalid input: '&P'
- code for "current page #"
- invalid input: '&N'
- code for "total pages"
- invalid input: '&font' size
- code for "text font size", where font size is a font size in points.
- invalid input: '&K'
- code for "text font color" RGB Color is specified as RRGGBB Theme Color is specifed as TTSNN where TT is the theme color Id, S is either "+" or "-" of the tint/shade value, NN is the tint/shade value.
- invalid input: '&S'
- code for "text strikethrough" on / off
- invalid input: '&X'
- code for "text super script" on / off
- invalid input: '&Y'
- code for "text subscript" on / off
- invalid input: '&C'
- code for "center section". When two or more occurrences of this section marker exist, the contents from all markers are concatenated, in the order of appearance, and placed into the center section. SpreadsheetML Reference Material - Worksheets 1966
- invalid input: '&D'
- code for "date"
- invalid input: '&T'
- code for "time"
- invalid input: '&G'
- code for "picture as background"
- invalid input: '&U'
- code for "text single underline"
- invalid input: '&E'
- code for "double underline"
- invalid input: '&R'
- code for "right section". When two or more occurrences of this section marker exist, the contents from all markers are concatenated, in the order of appearance, and placed into the right section.
- invalid input: '&Z'
- code for "this workbook's file path"
- invalid input: '&F'
- code for "this workbook's file name"
- invalid input: '&A'
- code for "sheet tab name"
- invalid input: '&'+
- code for add to page #.
- invalid input: '&'-
- code for subtract from page #.
- invalid input: '&'"font name,font type" - code for "text font name" and "text font type",
where font name and font type are strings specifying the name and type of the
font, separated by a comma. When a hyphen appears in font name, it means
"none specified". Both of font name and font type can be localized
values.
- invalid input: '&'"-,Bold"
- code for "bold font style"
- invalid input: '&B'
- also means "bold font style"
- invalid input: '&'"-,Regular"
- code for "regular font style"
- invalid input: '&'"-,Italic"
- code for "italic font style"
- invalid input: '&I'
- also means "italic font style"
- invalid input: '&'"-,Bold Italic"
- code for "bold italic font style"
- invalid input: '&O'
- code for "outline style"
- invalid input: '&H'
- code for "shadow style"
-
Constructor Summary
ConstructorsConstructorDescriptionXSSFHeaderFooter
(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter headerFooter) Create an instance of XSSFAbstractHeaderFooter from the supplied XML bean -
Method Summary
Modifier and TypeMethodDescriptionboolean
Are fields currently being stripped from the text that thisXSSFHeaderFooter
returns? Default is false, but can be changedget the text representing the center part of this elementorg.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter
Returns the underlying CTHeaderFooter xml beangetLeft()
get the text representing the left part of this elementgetRight()
get the text representing the right part of this elementabstract String
getText()
getValue()
Returns the value of the header or footer.void
setAreFieldsStripped
(boolean stripFields) Should fields (eg macros) be stripped from the text that this class returns? Default is not to strip.void
set a centered string value for this elementvoid
set a left string value for this elementvoid
set a right string value for this elementprotected abstract void
static String
stripFields
(String text) Removes any fields (eg macros, page markers etc) from the string.
-
Constructor Details
-
Method Details
-
getValue
Returns the value of the header or footer.- Returns:
- the value of the header or footer.
-
areFieldsStripped
public boolean areFieldsStripped()Are fields currently being stripped from the text that thisXSSFHeaderFooter
returns? Default is false, but can be changed -
setAreFieldsStripped
public void setAreFieldsStripped(boolean stripFields) Should fields (eg macros) be stripped from the text that this class returns? Default is not to strip.- Parameters:
stripFields
-
-
stripFields
Removes any fields (eg macros, page markers etc) from the string. Normally used to make some text suitable for showing to humans, and the resultant text should not normally be saved back into the document! -
getText
-
setText
-
getCenter
get the text representing the center part of this element- Specified by:
getCenter
in interfaceHeaderFooter
- Returns:
- The string representing the center.
-
getLeft
get the text representing the left part of this element- Specified by:
getLeft
in interfaceHeaderFooter
- Returns:
- The string representing the left side.
-
getRight
get the text representing the right part of this element- Specified by:
getRight
in interfaceHeaderFooter
- Returns:
- The string representing the right side.
-
setCenter
set a centered string value for this element- Specified by:
setCenter
in interfaceHeaderFooter
- Parameters:
newCenter
- The string to set as the center.
-
setLeft
set a left string value for this element- Specified by:
setLeft
in interfaceHeaderFooter
- Parameters:
newLeft
- The string to set as the left side.
-
setRight
set a right string value for this element- Specified by:
setRight
in interfaceHeaderFooter
- Parameters:
newRight
- The string to set as the right side.