ExcelFont module
- class ExcelFont.ExcelFont
Bases:
SpireObject,IFontRepresents a font in an Excel workbook.
This class encapsulates the properties and methods for managing font formatting in Excel, including font name, size, style (bold, italic, etc.), color, and other attributes. It implements the IFont interface to provide standard font manipulation functionality.
- BeginUpdate()
Begins a batch update operation on the font.
This method marks the start of a series of changes to the font properties. Multiple property changes can be made more efficiently by calling BeginUpdate before making the changes and EndUpdate after all changes are complete.
- property Color: Color
Gets or sets the primary color of the font using RGB values.
- Returns:
A Color object representing the RGB color of the font.
- Return type:
Color
- EndUpdate()
Ends a batch update operation on the font.
This method should be called after BeginUpdate and all desired property changes have been made. It applies all pending changes to the font properties.
- property FontName: str
Returns or sets the font name. Read / write string.
- GenerateNativeFont() Font
Generates a system font object based on this Excel font.
This method creates a Font object that can be used with the system’s drawing functions, representing the same visual attributes as this Excel font.
- Returns:
A system Font object with the same properties as this Excel font.
- Return type:
- property IsAutoColor: bool
Gets whether the font color is automatically selected.
When True, Excel automatically determines the font color based on the background or other contextual factors.
- Returns:
True if the font color is automatically selected; otherwise, False.
- Return type:
bool
- property IsBold: bool
True if the font is bold.
- property IsItalic: bool
Gets or sets whether the font style is italic.
- Returns:
True if the font style is italic; otherwise, False.
- Return type:
bool
- property IsStrikethrough: bool
True if the font is struck through with a horizontal line. Read / write Boolean
- property IsSubscript: bool
True if the font is formatted as subscript. False by default. Read / write Boolean.
- property IsSuperscript: bool
True if the font is formatted as superscript. False by default. Read/write Boolean
- property KnownColor: ExcelColors
Gets or sets the primary Excel color of the font using predefined Excel colors.
- Returns:
An enumeration value representing the predefined Excel color.
- Return type:
ExcelColors
- property Parent: SpireObject
Gets the parent object of this font.
The parent object is typically the cell, range, or style that contains this font.
- Returns:
The parent object that contains this font.
- Return type:
SpireObject
- SetThemeColor(type: ThemeColorType, tint: float)
Sets the theme color for the font.
- Parameters:
type (ThemeColorType) – The theme color type to apply.
tint (float) – The tint value to apply to the theme color, between -1.0 and 1.0. Positive values lighten the color, negative values darken it.
- property Size: float
Returns or sets the size of the font. Read / write integer.
- property StrikethroughType: str
- property Underline: FontUnderlineType
Gets or sets the type of underline applied to the font.
This property allows for different underline styles such as single, double, accounting, etc.
- Returns:
An enumeration value representing the underline type.
- Return type:
FontUnderlineType
- property VerticalAlignment: FontVertialAlignmentType
Gets or sets the vertical alignment of the font.
This property controls whether text appears as normal, subscript, or superscript.
- Returns:
An enumeration value representing the vertical alignment.
- Return type:
FontVertialAlignmentType
