Skip to content

ThemeManager

Manages a workbook’s theme, allowing users to get and set its properties.

isDefault: boolean;

true when this ThemeManager was created without an explicit theme, so the Office default was substituted. Flipped to false by any of the setter methods (set, setColorScheme, setMajorFont, setMinorFont, addCustomColor, removeCustomColor).

addCustomColor(color): void;

Adds a custom colour to the current theme.

ThemeCustomColor

void


get(): Readonly<Theme>;

Returns the current theme.

Readonly<Theme>


getColorScheme(): Readonly<ThemeColorScheme>;

Returns the current theme’s colour scheme.

A colour scheme acts as a colour palette for your workbook. It includes a twelve colours such as accent1, dk2, and hlink.

Readonly<ThemeColorScheme>


getCustomColors(): readonly ThemeCustomColor[];

Returns the current theme’s custom colours.

Custom colours are user-defined colours that can be used in a workbook. They are not part of the theme’s colour scheme, but they can be used in a workbook alongside those colours.

readonly ThemeCustomColor[]


getMajorFont(): Readonly<ThemeFontCollection>;

Returns the current theme’s major font collection.

A major font collection is commonly used for headings and other prominent text in a workbook. Use the theme’s minor font collection for body text.

Readonly<ThemeFontCollection>

ThemeManager.getMinorFont.


getMinorFont(): Readonly<ThemeFontCollection>;

Returns the current theme’s minor font collection.

A minor font collection is commonly used for body text of a workbook. Use the theme’s major font collection for headings and other prominent text.

Readonly<ThemeFontCollection>

ThemeManager.getMinorFont.


removeCustomColor(index): void;

Removes a custom colour from the current theme by its index.

number

void

If the index is out of range.


set(theme): void;

Sets the current theme.

This will replace any existing theme in its entirety. If you only want to replace parts of a theme, try ThemeManager.setMajorFont, ThemeManager.setMinorFont, ThemeManager.setColorScheme, ThemeManager.addCustomColor, or ThemeManager.removeCustomColor.

Sets isDefault to false.

Theme

void

// Copy the theme from another workbook.
workbook.theme.set(otherWorkbook.theme.get());

setColorScheme(scheme): void;

Sets the current theme’s colour scheme.

ThemeColorScheme

void


setMajorFont(font): void;

Sets the current theme’s major font collection.

ThemeFontCollection

void


setMinorFont(font): void;

Sets the current theme’s minor font collection.

ThemeFontCollection

void