Style class

Style class

Represents display style of excel document,such as font,color,alignment,border,etc. The Style object contains all style attributes (font, number format, alignment, and so on) as properties.

The Style type exposes the following members:

Constructors

ConstructorDescription
initInitializes a new instance of the Style class.

Properties

PropertyDescription
background_theme_colorGets and sets the background theme color.
foreground_theme_colorGets and sets the foreground theme color.
nameGets or sets the name of the style.
patternGets or sets the cell background pattern type.
bordersGets the BorderCollection of the style.
background_colorGets or sets a style’s background color.
background_argb_colorGets and sets the background color with a 32-bit ARGB value.
foreground_colorGets or sets a style’s foreground color.
foreground_argb_colorGets and sets the foreground color with a 32-bit ARGB value.
has_bordersChecks whether there are borders have been set for the style.
parent_styleGets the parent style of this style.
is_number_format_appliedIndicate whether the number formatting should be applied.
is_font_appliedIndicate whether the font formatting should be applied.
is_alignment_appliedIndicate whether the alignment formatting should be applied.
is_border_appliedIndicate whether the border formatting should be applied.
is_fill_appliedIndicate whether the fill formatting should be applied.
is_protection_appliedIndicate whether the protection formatting should be applied.
indent_levelRepresents the indent level for the cell or range. Can only be an integer from 0 to 250.
fontGets a Style.font object.
rotation_angleRepresents text rotation angle.
horizontal_alignmentGets or sets the horizontal alignment type of the text in a cell.
vertical_alignmentGets or sets the vertical alignment type of the text in a cell.
is_text_wrappedGets or sets a value indicating whether the text within a cell is wrapped.
numberGets or sets the display format of numbers and dates. The formatting patterns are different for different regions.
is_lockedGets or sets a value indicating whether a cell can be modified or not.
customRepresents the custom number format string of this style object.
If the custom number format is not set(For example, the number format is builtin), "" will be returned.
culture_customGets and sets the culture-dependent pattern string for number format.
If no number format has been set for this object, null will be returned.
If number format is builtin, the pattern string corresponding to the builtin number will be returned.
invariant_customGets the culture-independent pattern string for number format.
If no number format has been set for this object, null will be returned.
If number format is builtin, the pattern string corresponding to the builtin number will be returned.
is_formula_hiddenRepresents if the formula will be hidden when the worksheet is protected.
shrink_to_fitRepresents if text automatically shrinks to fit in the available column width.
text_directionRepresents text reading order.
is_justify_distributedIndicates if the cells justified or distributed alignment should be used on the last line of text.
quote_prefixIndicates whether the cell’s value starts with single quote mark.
is_gradientIndicates whether the cell shading is a gradient pattern.
is_percentIndicates whether the number format is a percent format.
is_date_timeIndicates whether the number format is a date format.

Methods

MethodDescription
set_borderSets the borders of the style.
set_borderSets the borders of the style.
set_pattern_colorSets the background color.
copyCopies data from another style object
updateApply the named style to the styles of the cells which use this named style.
It works like clicking the “ok” button after you finished modifying the style.
Only applies for named style.
is_modifiedChecks whether the specified properties of the style have been modified.
Used for style of ConditionalFormattings to check whether the specified properties of this style should be used when applying the ConditionalFormattings on a cell.
set_customSets the Custom number format string of a cell.
set_two_color_gradientSets the specified fill to a two-color gradient.
get_two_color_gradientGet the two-color gradient setting.
get_two_color_gradient_settingGet the two-color gradient setting.
to_jsonConvert Style to JSON struct data.

Example

from aspose.cells import Workbook
from aspose.pydrawing import Color

workbook = Workbook()
sheets = workbook.worksheets
cell = sheets[0].cells.get("A1")
style = cell.get_style()
style.font.name = "Times New Roman"
style.font.color = Color.blue
cell.set_style(style)

See Also