public enum FillPatternStyle extends Enum<FillPatternStyle>
Represents the style of fill pattern being used for a cell format.
Currently supported only in XLSX and XLS. For all other formats it defaults to either NONE
or SOLID
.
Conceptually, cell formatting is divided into following groups:
CellStyle.setNumberFormat(java.lang.String)
.
CellStyle.setHorizontalAlignment(com.gembox.spreadsheet.HorizontalAlignmentStyle)
, CellStyle.setVerticalAlignment(com.gembox.spreadsheet.VerticalAlignmentStyle)
, CellStyle.setIndent(int)
, CellStyle.setRotation(int)
, CellStyle.setTextVertical(boolean)
, CellStyle.setWrapText(boolean)
and CellStyle.setShrinkToFit(boolean)
.
CellStyle.setFont(com.gembox.spreadsheet.ExcelFont)
.
CellStyle.setBorders(com.gembox.spreadsheet.CellBorders)
.
CellStyle.setFillPattern(com.gembox.spreadsheet.ExcelFillPattern)
.
CellStyle.setLocked(boolean)
and CellStyle.setFormulaHidden(boolean)
.
Additional CellStyle
methods not associated with any formatting group are:
CellStyle.getName()
- name of the referenced workbook style
.
CellStyle.setQuotePrefix(boolean)
- true
to store numeric value of a cell as text; otherwise, false
.
CellStyle.isDefault()
- true
if referenced
workbook style
is default (
CellStyleCollection.getNormal()
) and there are no additional modifications of cell formatting; otherwise, false
.
Workbook
contains a set of master styles
which can be referenced by multiple cells.
Workbook
must always contain at least one master style
which cannot be removed and is, by default, referenced by all cells. This default style is
CellStyleCollection.getNormal()
.
Workbook style
can either be built-in or user-defined. Built-in style is accessible from workbook styles
via BuiltInCellStyleName
enumeration.
Cell formatting group (Number, Alignment, Font, Border, Fill or Protection) (and its associated methods) is resolved from referenced
workbook (master) style
, unless cell formatting group or its associated method is modified.
Cell formatting is available for one or more cells through AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method which is available on ExcelCell
and CellRange
types.
Cell formatting specified on ExcelColumn
and ExcelRow
types through ExcelColumnRowBase.setStyle(com.gembox.spreadsheet.CellStyle)
method is simply propagated to cell formatting of its ExcelColumnRowBase.getCells()
.
For performance reasons, cell formatting on CellRange
is resolved based just on its top-left cell formatting, except borders which are resolved based on corner cells depending on border side.
Setting cell formatting method on CellRange
is propagated to each cell in a range.
To set workbook (master) style
to one or more cells, simply assign it to AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method.
Preferable way to modify formatting method of multiple cells is to get CellRange
to which all those cells belong, and use AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method of that range to make the modification.
If modifying multiple formatting properties of a CellRange
, without preserving unmodified formatting properties, preferable way is to create new instance of CellStyle
, make modifications on it, and assign it using AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method of that range.
GemBox.Spreadsheet internally takes care not to allocate unnecessary cells when formatting a range of cells (for example, when formatting all worksheet cells
) and to cache formatting information of equally formatted cells, at the appropriate time, to reduce memory footprint.
// 'Fill' formatting group
sheet.getCell("B24").setValue("FillPattern.setPattern(...)");
sheet.getCell("C24").getStyle().getFillPattern().setPattern(FillPatternStyle.THIN_HORIZONTAL_CROSSHATCH, SpreadsheetColor.fromName(ColorName.GREEN), SpreadsheetColor.fromName(ColorName.YELLOW));
sheet.getCell("B25").setValue("FillPattern.setGradient(...)");
sheet.getCell("C25").getStyle().getFillPattern().setGradient(GradientShadingStyle.HORIZONTAL_HIGH, SpreadsheetColor.fromName(ColorName.GREEN), SpreadsheetColor.fromName(ColorName.YELLOW));
ExcelFillPattern.getPatternStyle()
Enum Constant and Description |
---|
DIAGONAL_CROSSHATCH
Diagonal Crosshatch pattern.
|
DIAGONAL_STRIPE
Diagonal Stripe pattern.
|
GRAY_12
12% Gray is Microsoft Excel pattern name, but any color can be used instead of black as a foreground color.
|
GRAY_25
25% Gray is Microsoft Excel pattern name, but any color can be used instead of black as a foreground color.
|
GRAY_50
50% Gray is Microsoft Excel pattern name, but any color can be used instead of black as a foreground color.
|
GRAY_6
6% Gray is Microsoft Excel pattern name, but any color can be used instead of black as a foreground color.
|
GRAY_75
75% Gray is Microsoft Excel pattern name, but any color can be used instead of black as a foreground color.
|
HORIZONTAL_STRIPE
Horizontal Stripe pattern.
|
NONE
The fill style is none (no fill).
|
REVERSE_DIAGONAL_STRIPE
Reverse Diagonal Stripe pattern.
|
SOLID
The fill style is solid.
|
THICK_DIAGONAL_CROSSHATCH
Thick Diagonal Crosshatch pattern.
|
THIN_DIAGONAL_CROSSHATCH
Thin Diagonal Crosshatch pattern.
|
THIN_DIAGONAL_STRIPE
Thin Diagonal Stripe pattern.
|
THIN_HORIZONTAL_CROSSHATCH
Thin Horizontal Crosshatch pattern.
|
THIN_HORIZONTAL_STRIPE
Thin Horizontal Stripe pattern.
|
THIN_REVERSE_DIAGONAL_STRIPE
Thin Reverse Diagonal Stripe pattern.
|
THIN_VERTICAL_STRIPE
Thin Vertical Stripe pattern.
|
VERTICAL_STRIPE
Vertical Stripe pattern.
|
Modifier and Type | Method and Description |
---|---|
static FillPatternStyle |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static FillPatternStyle[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final FillPatternStyle DIAGONAL_CROSSHATCH
public static final FillPatternStyle DIAGONAL_STRIPE
public static final FillPatternStyle GRAY_12
public static final FillPatternStyle GRAY_25
public static final FillPatternStyle GRAY_50
public static final FillPatternStyle GRAY_6
public static final FillPatternStyle GRAY_75
public static final FillPatternStyle HORIZONTAL_STRIPE
public static final FillPatternStyle NONE
The fill style is none (no fill).
When pattern foreground color
and/or pattern background color
are specified, a pattern of FillPatternStyle.NONE
overrides them and means the cell has no fill.
public static final FillPatternStyle REVERSE_DIAGONAL_STRIPE
public static final FillPatternStyle SOLID
The fill style is solid.
When solid is specified, the pattern foreground color
is the only color rendered, even when a pattern background color
is also specified.
public static final FillPatternStyle THICK_DIAGONAL_CROSSHATCH
public static final FillPatternStyle THIN_DIAGONAL_CROSSHATCH
public static final FillPatternStyle THIN_DIAGONAL_STRIPE
public static final FillPatternStyle THIN_HORIZONTAL_CROSSHATCH
public static final FillPatternStyle THIN_HORIZONTAL_STRIPE
public static final FillPatternStyle THIN_REVERSE_DIAGONAL_STRIPE
public static final FillPatternStyle THIN_VERTICAL_STRIPE
public static final FillPatternStyle VERTICAL_STRIPE
public static FillPatternStyle valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static FillPatternStyle[] values()
for (FillPatternStyle c : FillPatternStyle.values()) System.out.println(c);
© GemBox d.o.o. — All rights reserved.