OColor module

class OColor.OColor

Bases: SpireObject

This object used to store, convert colors.

property ColorType: ColorType

Returns type of the stored color.

Dispose()

Releases all resources used by the OColor object.

This method performs necessary cleanup operations and should be called when the object is no longer needed.

Equals(obj: SpireObject) bool

Determines whether the specified Object is equal to the current Object.

Parameters:

obj – The Object to compare with the current Object.

Returns:

true if the specified Object is equal to the current Object; otherwise, false.

GetHashCode() int

Returns the hash code for this instance.

Returns:

A 32-bit signed integer hash code.

GetKnownColor(book: Workbook) ExcelColors

Gets the Excel known color equivalent of this color.

This method attempts to match this color to one of the predefined Excel colors.

Parameters:

book (Workbook) – The workbook context for the color.

Returns:

An enumeration value representing the Excel known color.

Return type:

ExcelColors

SetKnownColor(value: ExcelColors)

Sets known color.

Parameters:

value – Excel color to set.

SetRGB(rgb: Color, book: IWorkbook, dTintValue: float)

Sets the color to an RGB color with a specified tint value.

This method sets the color to the specified RGB color and applies the specified tint value to lighten or darken the color.

Parameters:
  • rgb (Color) – The RGB color to set.

  • book (IWorkbook) – The workbook context for the color.

  • dTintValue (float) – The tint value to apply to the color. Positive values lighten the color, negative values darken it. Value should be between -1.0 and 1.0.

SetTheme

Sets the color to a theme color.

This method sets the color to a predefined theme color from the workbook’s theme.

Parameters:
  • themeIndex (int) – The index of the theme color.

  • book (IWorkbook) – The workbook containing the theme colors.

property Tint: float

Gets or sets Tint.

property Value: int

Returns color value (it can be index, rgb color, etc.)