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
Constructor | Description |
---|---|
init | Initializes a new instance of the Style class. |
Properties
Property | Description |
---|---|
background_theme_color | Gets and sets the background theme color. |
foreground_theme_color | Gets and sets the foreground theme color. |
name | Gets or sets the name of the style. |
pattern | Gets or sets the cell background pattern type. |
borders | Gets the BorderCollection of the style. |
background_color | Gets or sets a style’s background color. |
background_argb_color | Gets and sets the background color with a 32-bit ARGB value. |
foreground_color | Gets or sets a style’s foreground color. |
foreground_argb_color | Gets and sets the foreground color with a 32-bit ARGB value. |
has_borders | Checks whether there are borders have been set for the style. |
parent_style | Gets the parent style of this style. |
is_number_format_applied | Indicate whether the number formatting should be applied. |
is_font_applied | Indicate whether the font formatting should be applied. |
is_alignment_applied | Indicate whether the alignment formatting should be applied. |
is_border_applied | Indicate whether the border formatting should be applied. |
is_fill_applied | Indicate whether the fill formatting should be applied. |
is_protection_applied | Indicate whether the protection formatting should be applied. |
indent_level | Represents the indent level for the cell or range. Can only be an integer from 0 to 250. |
font | Gets a Style.font object. |
rotation_angle | Represents text rotation angle. |
horizontal_alignment | Gets or sets the horizontal alignment type of the text in a cell. |
vertical_alignment | Gets or sets the vertical alignment type of the text in a cell. |
is_text_wrapped | Gets or sets a value indicating whether the text within a cell is wrapped. |
number | Gets or sets the display format of numbers and dates. The formatting patterns are different for different regions. |
is_locked | Gets or sets a value indicating whether a cell can be modified or not. |
custom | Represents 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_custom | Gets 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_custom | Gets 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_hidden | Represents if the formula will be hidden when the worksheet is protected. |
shrink_to_fit | Represents if text automatically shrinks to fit in the available column width. |
text_direction | Represents text reading order. |
is_justify_distributed | Indicates if the cells justified or distributed alignment should be used on the last line of text. |
quote_prefix | Indicates whether the cell’s value starts with single quote mark. |
is_gradient | Indicates whether the cell shading is a gradient pattern. |
is_percent | Indicates whether the number format is a percent format. |
is_date_time | Indicates whether the number format is a date format. |
Methods
Method | Description |
---|---|
set_border | Sets the borders of the style. |
set_border | Sets the borders of the style. |
set_pattern_color | Sets the background color. |
copy | Copies data from another style object |
update | Apply 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_modified | Checks 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_custom | Sets the Custom number format string of a cell. |
set_two_color_gradient | Sets the specified fill to a two-color gradient. |
get_two_color_gradient | Get the two-color gradient setting. |
get_two_color_gradient_setting | Get the two-color gradient setting. |
to_json | Convert 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
- module
aspose.cells
- class
BorderCollection
- class
Style