Package org.apache.poi.xssf.usermodel
Class XSSFNamedStyle
- java.lang.Object
-
- org.apache.poi.xssf.usermodel.XSSFNamedStyle
-
- All Implemented Interfaces:
CellStyle,NamedStyle
public class XSSFNamedStyle extends Object implements NamedStyle
- Since:
- 3.9.6
- Author:
- henri
-
-
Constructor Summary
Constructors Constructor Description XSSFNamedStyle(String name, boolean custom, int builtinId, int xfId, org.apache.poi.xssf.model.StylesTable stylesSource, org.apache.poi.xssf.model.ThemesTable theme)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloneStyleFrom(CellStyle source)Clones all the style information from another CellStyle, onto this one.HorizontalAlignmentgetAlignment()get the type of horizontal alignment for the cellBorderStylegetBorderBottom()get the type of border to use for the bottom border of the cellBorderStylegetBorderLeft()get the type of border to use for the left border of the cellBorderStylegetBorderRight()get the type of border to use for the right border of the cellBorderStylegetBorderTop()get the type of border to use for the top border of the cellshortgetBottomBorderColor()get the color to use for the left borderintgetBuiltinId()org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellStylegetCellStyle()shortgetDataFormat()get the index of the data format.StringgetDataFormatString()Get the format stringshortgetFillBackgroundColor()get the background fill color, if the fill is defined with an indexed color.ColorgetFillBackgroundColorColor()Gets the color object representing the current background fill, resolving indexes using the supplied workbook.shortgetFillForegroundColor()get the foreground fill color, if the fill is defined with an indexed color.ColorgetFillForegroundColorColor()Gets the color object representing the current foreground fill, resolving indexes using the supplied workbook.FillPatternTypegetFillPattern()Get the fill patternintgetFontIndex()gets the index of the font for this styleintgetFontIndexAsInt()gets the index of the font for this stylebooleangetHidden()get whether the cell's using this style are to be hiddenshortgetIndention()get the number of spaces to indent the text in the cellshortgetIndex()get the index within the Workbook (sequence within the collection of ExtendedFormat objects)shortgetLeftBorderColor()get the color to use for the left borderbooleangetLocked()get whether the cell's using this style are to be lockedStringgetName()booleangetQuotePrefixed()Is "Quote Prefix" or "123 Prefix" enabled for the cell? Having this on is somewhat (but not completely, seeIgnoredErrorType) like prefixing the cell value with a ' in ExcelshortgetRightBorderColor()get the color to use for the left bordershortgetRotation()get the degree of rotation for the text in the cell.booleangetShrinkToFit()Should the Cell be auto-sized by Excel to shrink it to fit if this text is too long?shortgetTopBorderColor()get the color to use for the top borderVerticalAlignmentgetVerticalAlignment()get the type of vertical alignment for the cellbooleangetWrapText()get whether the text should be wrappedbooleanisCustomBuiltin()voidsetAlignment(HorizontalAlignment align)set the type of horizontal alignment for the cellvoidsetBorderBottom(BorderStyle border)set the type of border to use for the bottom border of the cellvoidsetBorderLeft(BorderStyle border)set the type of border to use for the left border of the cellvoidsetBorderRight(BorderStyle border)set the type of border to use for the right border of the cellvoidsetBorderTop(BorderStyle border)set the type of border to use for the top border of the cellvoidsetBottomBorderColor(short color)set the color to use for the bottom bordervoidsetDataFormat(short fmt)set the data format (must be a valid format).voidsetFillBackgroundColor(short bg)set the background fill color.voidsetFillBackgroundColor(Color color)Set the background fill color.voidsetFillForegroundColor(short bg)set the foreground fill color Note: Ensure Foreground color is set prior to background color.voidsetFillForegroundColor(Color color)Set the foreground fill color.voidsetFillPattern(FillPatternType fp)setting to one fills the cell with the foreground color...voidsetFont(Font font)set the font for this stylevoidsetHidden(boolean hidden)set the cell's using this style to be hiddenvoidsetIndention(short indent)set the number of spaces to indent the text in the cellvoidsetLeftBorderColor(short color)set the color to use for the left bordervoidsetLocked(boolean locked)set the cell's using this style to be lockedvoidsetQuotePrefixed(boolean quotePrefix)Turn on or off "Quote Prefix" or "123 Prefix" for the style, which is used to tell Excel that the thing which looks like a number or a formula shouldn't be treated as on.voidsetRightBorderColor(short color)set the color to use for the right bordervoidsetRotation(short rotation)set the degree of rotation for the text in the cell.voidsetShrinkToFit(boolean shrinkToFit)Controls if the Cell should be auto-sized to shrink to fit if the text is too longvoidsetTopBorderColor(short color)set the color to use for the top bordervoidsetVerticalAlignment(VerticalAlignment align)set the type of vertical alignment for the cellvoidsetWrapText(boolean wrapped)Set whether the text should be wrapped.
-
-
-
Constructor Detail
-
XSSFNamedStyle
public XSSFNamedStyle(String name, boolean custom, int builtinId, int xfId, org.apache.poi.xssf.model.StylesTable stylesSource, org.apache.poi.xssf.model.ThemesTable theme)
-
-
Method Detail
-
getCellStyle
public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellStyle getCellStyle()
-
getName
public String getName()
- Specified by:
getNamein interfaceNamedStyle
-
isCustomBuiltin
public boolean isCustomBuiltin()
- Specified by:
isCustomBuiltinin interfaceNamedStyle
-
getBuiltinId
public int getBuiltinId()
- Specified by:
getBuiltinIdin interfaceNamedStyle
-
getIndex
public short getIndex()
Description copied from interface:CellStyleget the index within the Workbook (sequence within the collection of ExtendedFormat objects)
-
setDataFormat
public void setDataFormat(short fmt)
Description copied from interface:CellStyleset the data format (must be a valid format). Built in formats are defined atBuiltinFormats.- Specified by:
setDataFormatin interfaceCellStyle- See Also:
DataFormat
-
getDataFormat
public short getDataFormat()
Description copied from interface:CellStyleget the index of the data format. Built in formats are defined atBuiltinFormats.- Specified by:
getDataFormatin interfaceCellStyle- See Also:
DataFormat
-
getDataFormatString
public String getDataFormatString()
Description copied from interface:CellStyleGet the format string- Specified by:
getDataFormatStringin interfaceCellStyle
-
setFont
public void setFont(Font font)
Description copied from interface:CellStyleset the font for this style- Specified by:
setFontin interfaceCellStyle- Parameters:
font- a font object created or retrieved from the Workbook object- See Also:
Workbook.createFont(),Workbook.getFontAt(int)
-
getFontIndex
public int getFontIndex()
Description copied from interface:CellStylegets the index of the font for this style- Specified by:
getFontIndexin interfaceCellStyle- See Also:
Workbook.getFontAt(int)
-
getFontIndexAsInt
public int getFontIndexAsInt()
Description copied from interface:CellStylegets the index of the font for this style- Specified by:
getFontIndexAsIntin interfaceCellStyle- See Also:
Workbook.getFontAt(int)
-
setHidden
public void setHidden(boolean hidden)
Description copied from interface:CellStyleset the cell's using this style to be hidden
-
getHidden
public boolean getHidden()
Description copied from interface:CellStyleget whether the cell's using this style are to be hidden
-
setLocked
public void setLocked(boolean locked)
Description copied from interface:CellStyleset the cell's using this style to be locked
-
getLocked
public boolean getLocked()
Description copied from interface:CellStyleget whether the cell's using this style are to be locked
-
setQuotePrefixed
public void setQuotePrefixed(boolean quotePrefix)
Description copied from interface:CellStyleTurn on or off "Quote Prefix" or "123 Prefix" for the style, which is used to tell Excel that the thing which looks like a number or a formula shouldn't be treated as on. Turning this on is somewhat (but not completely, seeIgnoredErrorType) like prefixing the cell value with a ' in Excel- Specified by:
setQuotePrefixedin interfaceCellStyle
-
getQuotePrefixed
public boolean getQuotePrefixed()
Description copied from interface:CellStyleIs "Quote Prefix" or "123 Prefix" enabled for the cell? Having this on is somewhat (but not completely, seeIgnoredErrorType) like prefixing the cell value with a ' in Excel- Specified by:
getQuotePrefixedin interfaceCellStyle
-
setAlignment
public void setAlignment(HorizontalAlignment align)
Description copied from interface:CellStyleset the type of horizontal alignment for the cell- Specified by:
setAlignmentin interfaceCellStyle- Parameters:
align- - the type of alignment
-
getAlignment
public HorizontalAlignment getAlignment()
Description copied from interface:CellStyleget the type of horizontal alignment for the cell- Specified by:
getAlignmentin interfaceCellStyle- Returns:
- align - the type of alignment
-
setWrapText
public void setWrapText(boolean wrapped)
Description copied from interface:CellStyleSet whether the text should be wrapped. Setting this flag totruemake all content visible within a cell by displaying it on multiple lines- Specified by:
setWrapTextin interfaceCellStyle- Parameters:
wrapped- wrap text or not
-
getWrapText
public boolean getWrapText()
Description copied from interface:CellStyleget whether the text should be wrapped- Specified by:
getWrapTextin interfaceCellStyle- Returns:
- wrap text or not
-
setVerticalAlignment
public void setVerticalAlignment(VerticalAlignment align)
Description copied from interface:CellStyleset the type of vertical alignment for the cell- Specified by:
setVerticalAlignmentin interfaceCellStyle- Parameters:
align- the type of alignment
-
getVerticalAlignment
public VerticalAlignment getVerticalAlignment()
Description copied from interface:CellStyleget the type of vertical alignment for the cell- Specified by:
getVerticalAlignmentin interfaceCellStyle- Returns:
- align the type of alignment
-
setRotation
public void setRotation(short rotation)
Description copied from interface:CellStyleset the degree of rotation for the text in the cell. Note: HSSF uses values from -90 to 90 degrees, whereas XSSF uses values from 0 to 180 degrees. The implementations of this method will map between these two value-ranges accordingly, however the corresponding getter is returning values in the range mandated by the current type of Excel file-format that this CellStyle is applied to.- Specified by:
setRotationin interfaceCellStyle- Parameters:
rotation- degrees (see note above)
-
getRotation
public short getRotation()
Description copied from interface:CellStyleget the degree of rotation for the text in the cell. Note: HSSF uses values from -90 to 90 degrees, whereas XSSF uses values from 0 to 180 degrees. The implementations of this method will map between these two value-ranges value-range as used by the type of Excel file-format that this CellStyle is applied to.- Specified by:
getRotationin interfaceCellStyle- Returns:
- rotation degrees (see note above)
-
setIndention
public void setIndention(short indent)
Description copied from interface:CellStyleset the number of spaces to indent the text in the cell- Specified by:
setIndentionin interfaceCellStyle- Parameters:
indent- - number of spaces
-
getIndention
public short getIndention()
Description copied from interface:CellStyleget the number of spaces to indent the text in the cell- Specified by:
getIndentionin interfaceCellStyle- Returns:
- indent - number of spaces
-
setBorderLeft
public void setBorderLeft(BorderStyle border)
Description copied from interface:CellStyleset the type of border to use for the left border of the cell- Specified by:
setBorderLeftin interfaceCellStyle- Parameters:
border- type
-
getBorderLeft
public BorderStyle getBorderLeft()
Description copied from interface:CellStyleget the type of border to use for the left border of the cell- Specified by:
getBorderLeftin interfaceCellStyle- Returns:
- border type
-
setBorderRight
public void setBorderRight(BorderStyle border)
Description copied from interface:CellStyleset the type of border to use for the right border of the cell- Specified by:
setBorderRightin interfaceCellStyle- Parameters:
border- type
-
getBorderRight
public BorderStyle getBorderRight()
Description copied from interface:CellStyleget the type of border to use for the right border of the cell- Specified by:
getBorderRightin interfaceCellStyle- Returns:
- border type
-
setBorderTop
public void setBorderTop(BorderStyle border)
Description copied from interface:CellStyleset the type of border to use for the top border of the cell- Specified by:
setBorderTopin interfaceCellStyle- Parameters:
border- type
-
getBorderTop
public BorderStyle getBorderTop()
Description copied from interface:CellStyleget the type of border to use for the top border of the cell- Specified by:
getBorderTopin interfaceCellStyle- Returns:
- border type
-
setBorderBottom
public void setBorderBottom(BorderStyle border)
Description copied from interface:CellStyleset the type of border to use for the bottom border of the cell- Specified by:
setBorderBottomin interfaceCellStyle- Parameters:
border- type
-
getBorderBottom
public BorderStyle getBorderBottom()
Description copied from interface:CellStyleget the type of border to use for the bottom border of the cell- Specified by:
getBorderBottomin interfaceCellStyle- Returns:
- border type
-
setLeftBorderColor
public void setLeftBorderColor(short color)
Description copied from interface:CellStyleset the color to use for the left border- Specified by:
setLeftBorderColorin interfaceCellStyle- Parameters:
color- The index of the color definition
-
getLeftBorderColor
public short getLeftBorderColor()
Description copied from interface:CellStyleget the color to use for the left border- Specified by:
getLeftBorderColorin interfaceCellStyle
-
setRightBorderColor
public void setRightBorderColor(short color)
Description copied from interface:CellStyleset the color to use for the right border- Specified by:
setRightBorderColorin interfaceCellStyle- Parameters:
color- The index of the color definition
-
getRightBorderColor
public short getRightBorderColor()
Description copied from interface:CellStyleget the color to use for the left border- Specified by:
getRightBorderColorin interfaceCellStyle- Returns:
- the index of the color definition
-
setTopBorderColor
public void setTopBorderColor(short color)
Description copied from interface:CellStyleset the color to use for the top border- Specified by:
setTopBorderColorin interfaceCellStyle- Parameters:
color- The index of the color definition
-
getTopBorderColor
public short getTopBorderColor()
Description copied from interface:CellStyleget the color to use for the top border- Specified by:
getTopBorderColorin interfaceCellStyle- Returns:
- the index of the color definition
-
setBottomBorderColor
public void setBottomBorderColor(short color)
Description copied from interface:CellStyleset the color to use for the bottom border- Specified by:
setBottomBorderColorin interfaceCellStyle- Parameters:
color- The index of the color definition
-
getBottomBorderColor
public short getBottomBorderColor()
Description copied from interface:CellStyleget the color to use for the left border- Specified by:
getBottomBorderColorin interfaceCellStyle- Returns:
- the index of the color definition
-
setFillPattern
public void setFillPattern(FillPatternType fp)
Description copied from interface:CellStylesetting to one fills the cell with the foreground color... No idea about other values- Specified by:
setFillPatternin interfaceCellStyle- Parameters:
fp- fill pattern (set toFillPatternType.SOLID_FOREGROUNDto fill w/foreground color)
-
getFillPattern
public FillPatternType getFillPattern()
Description copied from interface:CellStyleGet the fill pattern- Specified by:
getFillPatternin interfaceCellStyle- Returns:
- the fill pattern, default value is
FillPatternType.NO_FILL
-
setFillBackgroundColor
public void setFillBackgroundColor(short bg)
Description copied from interface:CellStyleset the background fill color.- Specified by:
setFillBackgroundColorin interfaceCellStyle- Parameters:
bg- color
-
setFillBackgroundColor
public void setFillBackgroundColor(Color color)
Description copied from interface:CellStyleSet the background fill color. Uses aColorinstead of an indexed color.- Specified by:
setFillBackgroundColorin interfaceCellStyle- Parameters:
color- org.apache.poi.ss.usermodel.Color to set
-
getFillBackgroundColor
public short getFillBackgroundColor()
Description copied from interface:CellStyleget the background fill color, if the fill is defined with an indexed color.- Specified by:
getFillBackgroundColorin interfaceCellStyle- Returns:
- fill color index, or 0 if not indexed (XSSF only)
-
getFillBackgroundColorColor
public Color getFillBackgroundColorColor()
Description copied from interface:CellStyleGets the color object representing the current background fill, resolving indexes using the supplied workbook. This will work for both indexed and rgb defined colors.- Specified by:
getFillBackgroundColorColorin interfaceCellStyle
-
setFillForegroundColor
public void setFillForegroundColor(short bg)
Description copied from interface:CellStyleset the foreground fill color Note: Ensure Foreground color is set prior to background color.- Specified by:
setFillForegroundColorin interfaceCellStyle- Parameters:
bg- color
-
setFillForegroundColor
public void setFillForegroundColor(Color color)
Description copied from interface:CellStyleSet the foreground fill color. Uses aColorinstead of an indexed color.- Specified by:
setFillForegroundColorin interfaceCellStyle- Parameters:
color- org.apache.poi.ss.usermodel.Color to set
-
getFillForegroundColor
public short getFillForegroundColor()
Description copied from interface:CellStyleget the foreground fill color, if the fill is defined with an indexed color.- Specified by:
getFillForegroundColorin interfaceCellStyle- Returns:
- fill color, or 0 if not indexed (XSSF only)
-
getFillForegroundColorColor
public Color getFillForegroundColorColor()
Description copied from interface:CellStyleGets the color object representing the current foreground fill, resolving indexes using the supplied workbook. This will work for both indexed and rgb defined colors.- Specified by:
getFillForegroundColorColorin interfaceCellStyle
-
cloneStyleFrom
public void cloneStyleFrom(CellStyle source)
Description copied from interface:CellStyleClones all the style information from another CellStyle, onto this one. This CellStyle will then have all the same properties as the source, but the two may be edited independently. Any stylings on this CellStyle will be lost! The source CellStyle could be from another Workbook if you like. This allows you to copy styles from one Workbook to another. However, both of the CellStyles will need to be of the same type (HSSFCellStyle or XSSFCellStyle)- Specified by:
cloneStyleFromin interfaceCellStyle
-
setShrinkToFit
public void setShrinkToFit(boolean shrinkToFit)
Description copied from interface:CellStyleControls if the Cell should be auto-sized to shrink to fit if the text is too long- Specified by:
setShrinkToFitin interfaceCellStyle
-
getShrinkToFit
public boolean getShrinkToFit()
Description copied from interface:CellStyleShould the Cell be auto-sized by Excel to shrink it to fit if this text is too long?- Specified by:
getShrinkToFitin interfaceCellStyle
-
-