public class Style
extends java.lang.Object
Example
Workbook workbook = new Workbook();
WorksheetCollection sheets = workbook.getWorksheets();
Cell cell = sheets.get(0).getCells().get("A1");
Style style = cell.getStyle();
style.getFont().setName("Times New Roman");
style.getFont().setColor(Color.getBlue());
cell.setStyle(style);
| Constructor and Description |
|---|
Style()
Deprecated.
Use CellsFactory.CreateStyle() method instead.
|
| Modifier and Type | Method and Description |
|---|---|
void |
copy(Style style)
Copies data from another style object
|
boolean |
equals(java.lang.Object obj)
Determines whether two Style instances are equal.
|
int |
getBackgroundArgbColor()
Gets the background color with a 32-bit ARGB value.
|
Color |
getBackgroundColor()
Gets a style's background color.
|
ThemeColor |
getBackgroundThemeColor()
Gets the background theme color.
|
BorderCollection |
getBorders()
Gets the
BorderCollection of the style. |
java.lang.String |
getCultureCustom()
Gets the culture-dependent pattern string for number format.
|
java.lang.String |
getCustom()
Represents the custom number format string of this style object.
|
Font |
getFont()
Gets a
ChartArea.getFont() object. |
int |
getForegroundArgbColor()
Gets the foreground color with a 32-bit ARGB value.
|
Color |
getForegroundColor()
Gets a style's foreground color.
|
ThemeColor |
getForegroundThemeColor()
Gets the foreground theme color.
|
int |
getHorizontalAlignment()
Gets the horizontal alignment type of the text in a cell.
|
int |
getIndentLevel()
Represents the indent level for the cell or range.
|
java.lang.String |
getInvariantCustom()
Gets the culture-independent pattern string for number format.
|
java.lang.String |
getName()
Gets the name of the style.
|
int |
getNumber()
Gets the display format of numbers and dates.
|
Style |
getParentStyle()
Gets the parent style of this style.
|
int |
getPattern()
Gets the cell background pattern type.
|
boolean |
getQuotePrefix()
Indicates whether the cell's value starts with single quote mark.
|
int |
getRotationAngle()
Represents text rotation angle.
|
boolean |
getShrinkToFit()
Represents if text automatically shrinks to fit in the available column width.
|
int |
getTextDirection()
Represents text reading order.
|
java.lang.Object[] |
getTwoColorGradient()
Deprecated.
Use Style.GetTwoColorGradientSetting() method instead.
|
TwoColorGradient |
getTwoColorGradientSetting()
Get the two-color gradient setting.
|
int |
getVerticalAlignment()
Gets the vertical alignment type of the text in a cell.
|
boolean |
hasBorders()
Checks whether there are borders have been set for the style.
|
int |
hashCode()
Serves as a hash function for a Style object.
|
boolean |
isAlignmentApplied()
Indicate whether the alignment formatting should be applied.
|
boolean |
isBorderApplied()
Indicate whether the border formatting should be applied.
|
boolean |
isDateTime()
Indicates whether the number format is a date format.
|
boolean |
isFillApplied()
Indicate whether the fill formatting should be applied.
|
boolean |
isFontApplied()
Indicate whether the font formatting should be applied.
|
boolean |
isFormulaHidden()
Represents if the formula will be hidden when the worksheet is protected.
|
boolean |
isGradient()
Indicates whether the cell shading is a gradient pattern.
|
boolean |
isJustifyDistributed()
Indicates if the cells justified or distributed alignment should be used on the last line of text.
|
boolean |
isLocked()
Gets a value indicating whether a cell can be modified or not.
|
boolean |
isModified(int modifyFlag)
Checks whether the specified properties of the style have been modified.
|
boolean |
isNumberFormatApplied()
Indicate whether the number formatting should be applied.
|
boolean |
isPercent()
Indicates whether the number format is a percent format.
|
boolean |
isProtectionApplied()
Indicate whether the protection formatting should be applied.
|
boolean |
isTextWrapped()
Gets a value indicating whether the text within a cell is wrapped.
|
void |
setAlignmentApplied(boolean value)
Indicate whether the alignment formatting should be applied.
|
void |
setBackgroundArgbColor(int value)
Sets the background color with a 32-bit ARGB value.
|
void |
setBackgroundColor(Color value)
Sets a style's background color.
|
void |
setBackgroundThemeColor(ThemeColor value)
Sets the background theme color.
|
boolean |
setBorder(int borderType,
int borderStyle,
CellsColor borderColor)
Sets the borders of the style.
|
boolean |
setBorder(int borderType,
int borderStyle,
Color borderColor)
Sets the borders of the style.
|
void |
setBorderApplied(boolean value)
Indicate whether the border formatting should be applied.
|
void |
setCultureCustom(java.lang.String value)
Sets the culture-dependent pattern string for number format.
|
void |
setCustom(java.lang.String value)
Represents the custom number format string of this style object.
|
void |
setCustom(java.lang.String custom,
boolean builtinPreference)
Sets the Custom number format string of a cell.
|
void |
setFillApplied(boolean value)
Indicate whether the fill formatting should be applied.
|
void |
setFontApplied(boolean value)
Indicate whether the font formatting should be applied.
|
void |
setForegroundArgbColor(int value)
Sets the foreground color with a 32-bit ARGB value.
|
void |
setForegroundColor(Color value)
Sets a style's foreground color.
|
void |
setForegroundThemeColor(ThemeColor value)
Sets the foreground theme color.
|
void |
setFormulaHidden(boolean value)
Represents if the formula will be hidden when the worksheet is protected.
|
void |
setGradient(boolean value)
Indicates whether the cell shading is a gradient pattern.
|
void |
setHorizontalAlignment(int value)
Sets the horizontal alignment type of the text in a cell.
|
void |
setIndentLevel(int value)
Represents the indent level for the cell or range.
|
void |
setJustifyDistributed(boolean value)
Indicates if the cells justified or distributed alignment should be used on the last line of text.
|
void |
setLocked(boolean value)
Sets a value indicating whether a cell can be modified or not.
|
void |
setName(java.lang.String value)
Sets the name of the style.
|
void |
setNumber(int value)
Sets the display format of numbers and dates.
|
void |
setNumberFormatApplied(boolean value)
Indicate whether the number formatting should be applied.
|
void |
setPattern(int value)
Sets the cell background pattern type.
|
void |
setPatternColor(int pattern,
Color color1,
Color color2)
Sets the background color.
|
void |
setProtectionApplied(boolean value)
Indicate whether the protection formatting should be applied.
|
void |
setQuotePrefix(boolean value)
Indicates whether the cell's value starts with single quote mark.
|
void |
setRotationAngle(int value)
Represents text rotation angle.
|
void |
setShrinkToFit(boolean value)
Represents if text automatically shrinks to fit in the available column width.
|
void |
setTextDirection(int value)
Represents text reading order.
|
void |
setTextWrapped(boolean value)
Sets a value indicating whether the text within a cell is wrapped.
|
void |
setTwoColorGradient(Color color1,
Color color2,
int gradientStyleType,
int variant)
Sets the specified fill to a two-color gradient.
|
void |
setVerticalAlignment(int value)
Sets the vertical alignment type of the text in a cell.
|
java.lang.String |
toJson()
Convert
Style to JSON struct data. |
void |
update()
Apply the named style to the styles of the cells which use this named style.
|
public Style()
Style class.
Remarks
NOTE: This constructor is now obsolete. Instead, please use CellsFactory.CreateStyle() method. This property will be removed 6 months later since October 2016. Aspose apologizes for any inconvenience you may have experienced.public ThemeColor getBackgroundThemeColor()
Remarks
If the background color is not a theme color, NULL will be returned.public void setBackgroundThemeColor(ThemeColor value)
Remarks
If the background color is not a theme color, NULL will be returned.public ThemeColor getForegroundThemeColor()
Remarks
If the foreground color is not a theme color, NULL will be returned.public void setForegroundThemeColor(ThemeColor value)
Remarks
If the foreground color is not a theme color, NULL will be returned.public java.lang.String getName()
public void setName(java.lang.String value)
public int getPattern()
See BackgroundType.
public void setPattern(int value)
See BackgroundType.
public void setPatternColor(int pattern,
Color color1,
Color color2)
pattern - BackgroundType. The pattern.color1 - The foreground color.color2 - The background color. Only works when pattern is not BackgroundType.None and BackgroundType.Solid.public BorderCollection getBorders()
BorderCollection of the style.public Color getBackgroundColor()
Remarks
If you want to set a cell's color, please use Style.ForegroundColor property. Only if the cell style pattern is other than none or solid, this property will take effect.public void setBackgroundColor(Color value)
Remarks
If you want to set a cell's color, please use Style.ForegroundColor property. Only if the cell style pattern is other than none or solid, this property will take effect.public int getBackgroundArgbColor()
public void setBackgroundArgbColor(int value)
public Color getForegroundColor()
Remarks
It means no color setting if Color.Empty is returned.public void setForegroundColor(Color value)
Remarks
It means no color setting if Color.Empty is returned.public int getForegroundArgbColor()
public void setForegroundArgbColor(int value)
public void copy(Style style)
Remarks
This method does not copy the name of the style. If you want to copy the name, please call the following codes after copying style: destStyle.Name = style.Name.style - Source Style objectpublic boolean hasBorders()
public Style getParentStyle()
public void update()
public boolean isNumberFormatApplied()
Remarks
Only for named style.public void setNumberFormatApplied(boolean value)
Remarks
Only for named style.public boolean isFontApplied()
Remarks
Only for named style.public void setFontApplied(boolean value)
Remarks
Only for named style.public boolean isAlignmentApplied()
Remarks
Only for named style.public void setAlignmentApplied(boolean value)
Remarks
Only for named style.public boolean isBorderApplied()
Remarks
Only for named style.public void setBorderApplied(boolean value)
Remarks
Only for named style.public boolean isFillApplied()
Remarks
Only for named style.public void setFillApplied(boolean value)
Remarks
Only for named style.public boolean isProtectionApplied()
Remarks
Only for named style.public void setProtectionApplied(boolean value)
Remarks
Only for named style.public boolean isModified(int modifyFlag)
modifyFlag - StyleModifyFlag. Style modified flagspublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - The Style object to compare with the current Style object.public int hashCode()
Remarks
This method is only for internal use.hashCode in class java.lang.Objectpublic int getIndentLevel()
Remarks
If text horizontal alignment type is set to value other than left or right, indent level will be reset to zero.public void setIndentLevel(int value)
Remarks
If text horizontal alignment type is set to value other than left or right, indent level will be reset to zero.public Font getFont()
ChartArea.getFont() object.public int getRotationAngle()
Remarks
0: Not rotated.
255: Top to Bottom.
-90: Downward.
90: Upward.
You can set 255 or value ranged from -90 to 90.public void setRotationAngle(int value)
Remarks
0: Not rotated.
255: Top to Bottom.
-90: Downward.
90: Upward.
You can set 255 or value ranged from -90 to 90.public int getHorizontalAlignment()
See TextAlignmentType.
public void setHorizontalAlignment(int value)
See TextAlignmentType.
public int getVerticalAlignment()
See TextAlignmentType.
public void setVerticalAlignment(int value)
See TextAlignmentType.
public boolean isTextWrapped()
public void setTextWrapped(boolean value)
public int getNumber()
Remarks
For example, the formatting patterns represented by numbers for en_US region:| Value | Type | Format String |
|---|---|---|
| 0 | General | General |
| 1 | Decimal | 0 |
| 2 | Decimal | 0.00 |
| 3 | Decimal | #,##0 |
| 4 | Decimal | #,##0.00 |
| 5 | Currency | $#,##0_);($#,##0) |
| 6 | Currency | $#,##0_);[Red]($#,##0) |
| 7 | Currency | $#,##0.00_);($#,##0.00) |
| 8 | Currency | $#,##0.00_);[Red]($#,##0.00) |
| 9 | Percentage | 0% |
| 10 | Percentage | 0.00% |
| 11 | Scientific | 0.00E+00 |
| 12 | Fraction | # ?/? |
| 13 | Fraction | # ??/?? |
| 14 | Date | m/d/yyyy |
| 15 | Date | d-mmm-yy |
| 16 | Date | d-mmm |
| 17 | Date | mmm-yy |
| 18 | Time | h:mm AM/PM |
| 19 | Time | h:mm:ss AM/PM |
| 20 | Time | h:mm |
| 21 | Time | h:mm:ss |
| 22 | Time | m/d/yyyy h:mm |
| 37 | Accounting | #,##0_);(#,##0) |
| 38 | Accounting | #,##0_);[Red](#,##0) |
| 39 | Accounting | #,##0.00_);(#,##0.00) |
| 40 | Accounting | #,##0.00_);[Red](#,##0.00) |
| 41 | Accounting | _(* #,##0_);_(* (#,##0);_(* "-"_);_(@_) |
| 42 | Currency | _($* #,##0_);_($* (#,##0);_($* "-"_);_(@_) |
| 43 | Accounting | _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_) |
| 44 | Currency | _($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_) |
| 45 | Time | mm:ss |
| 46 | Time | [h]:mm:ss |
| 47 | Time | mm:ss.0 |
| 48 | Scientific | ##0.0E+0 |
| 49 | Text | @ |
public void setNumber(int value)
Remarks
For example, the formatting patterns represented by numbers for en_US region:| Value | Type | Format String |
|---|---|---|
| 0 | General | General |
| 1 | Decimal | 0 |
| 2 | Decimal | 0.00 |
| 3 | Decimal | #,##0 |
| 4 | Decimal | #,##0.00 |
| 5 | Currency | $#,##0_);($#,##0) |
| 6 | Currency | $#,##0_);[Red]($#,##0) |
| 7 | Currency | $#,##0.00_);($#,##0.00) |
| 8 | Currency | $#,##0.00_);[Red]($#,##0.00) |
| 9 | Percentage | 0% |
| 10 | Percentage | 0.00% |
| 11 | Scientific | 0.00E+00 |
| 12 | Fraction | # ?/? |
| 13 | Fraction | # ??/?? |
| 14 | Date | m/d/yyyy |
| 15 | Date | d-mmm-yy |
| 16 | Date | d-mmm |
| 17 | Date | mmm-yy |
| 18 | Time | h:mm AM/PM |
| 19 | Time | h:mm:ss AM/PM |
| 20 | Time | h:mm |
| 21 | Time | h:mm:ss |
| 22 | Time | m/d/yyyy h:mm |
| 37 | Accounting | #,##0_);(#,##0) |
| 38 | Accounting | #,##0_);[Red](#,##0) |
| 39 | Accounting | #,##0.00_);(#,##0.00) |
| 40 | Accounting | #,##0.00_);[Red](#,##0.00) |
| 41 | Accounting | _(* #,##0_);_(* (#,##0);_(* "-"_);_(@_) |
| 42 | Currency | _($* #,##0_);_($* (#,##0);_($* "-"_);_(@_) |
| 43 | Accounting | _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_) |
| 44 | Currency | _($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_) |
| 45 | Time | mm:ss |
| 46 | Time | [h]:mm:ss |
| 47 | Time | mm:ss.0 |
| 48 | Scientific | ##0.0E+0 |
| 49 | Text | @ |
public boolean setBorder(int borderType,
int borderStyle,
Color borderColor)
borderType - BorderType. The border(s) to be set, can be combination of BorderType.borderStyle - CellBorderType. The style of the border.borderColor - The color of the border.public boolean setBorder(int borderType,
int borderStyle,
CellsColor borderColor)
borderType - BorderType. The border(s) to be set, can be combination of BorderType.borderStyle - CellBorderType. The style of the border.borderColor - The color of the border.public boolean isLocked()
Remarks
Locking cells has no effect unless the worksheet is protected.public void setLocked(boolean value)
Remarks
Locking cells has no effect unless the worksheet is protected.public void setCustom(java.lang.String custom,
boolean builtinPreference)
custom - Custom number format string, should be InvariantCulture pattern.builtinPreference - If given Custom number format string matches one of the built-in number formats
corresponding to current regional settings, whether set the number format as built-in instead of Custom.public java.lang.String getCustom()
Remarks
The returned custom string is culture-independent.public void setCustom(java.lang.String value)
Remarks
The returned custom string is culture-independent.public java.lang.String getCultureCustom()
Remarks
For builtin number format, both the pattern content(such as, one builtin date format is "m/d/y" for some locales, but for some other locales it becomes "d/m/y") and the format specifier(such as, some locales is using character other than 'y' to represent the year part for date formatting) are culture-dependent; For user specified custom format, only format specifiers are changed according to the culture, other parts of the formatting pattern will not be modified.public void setCultureCustom(java.lang.String value)
Remarks
For builtin number format, both the pattern content(such as, one builtin date format is "m/d/y" for some locales, but for some other locales it becomes "d/m/y") and the format specifier(such as, some locales is using character other than 'y' to represent the year part for date formatting) are culture-dependent; For user specified custom format, only format specifiers are changed according to the culture, other parts of the formatting pattern will not be modified.public java.lang.String getInvariantCustom()
Remarks
For builtin number formats, the returned pattern content is still culture-dependent, such as, for some locales it returns "m/d/y" and for some other locales it returns "d/m/y". The difference fromgetCultureCustom() is(that is also what culture-independent means):
the format specifiers and separators are kept as standard, such as '/' will always be used as datetime separator
and "y" will always be used as the "year" part no matter what other special character is used for the specific locale.public boolean isFormulaHidden()
public void setFormulaHidden(boolean value)
public boolean getShrinkToFit()
public void setShrinkToFit(boolean value)
public int getTextDirection()
See TextDirectionType.
public void setTextDirection(int value)
See TextDirectionType.
public boolean isJustifyDistributed()
Remarks
This is typical for East Asian alignments but not typical in other contexts.public void setJustifyDistributed(boolean value)
Remarks
This is typical for East Asian alignments but not typical in other contexts.public boolean getQuotePrefix()
public void setQuotePrefix(boolean value)
public boolean isGradient()
public void setGradient(boolean value)
public void setTwoColorGradient(Color color1, Color color2, int gradientStyleType, int variant)
color1 - One gradient color.color2 - Two gradient color.gradientStyleType - GradientStyleType. Gradient shading style.variant - The gradient variant. Can be a value from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If style is GradientStyle.FromCenter, the Variant argument can only be 1 or 2.public java.lang.Object[] getTwoColorGradient()
Remarks
NOTE: This method is now obsolete. Instead, please use Style.GetTwoColorGradientSetting() method. This property will be removed 12 months later since December 2022. Aspose apologizes for any inconvenience you may have experienced.public TwoColorGradient getTwoColorGradientSetting()
public boolean isPercent()
public boolean isDateTime()
public java.lang.String toJson()
Style to JSON struct data.See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.