ThemeManager
Manages a workbook’s theme, allowing users to get and set its properties.
Properties
Section titled “Properties”isDefault
Section titled “isDefault”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).
Methods
Section titled “Methods”addCustomColor()
Section titled “addCustomColor()”addCustomColor(color): void;Adds a custom colour to the current theme.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
get(): Readonly<Theme>;Returns the current theme.
Returns
Section titled “Returns”Readonly<Theme>
getColorScheme()
Section titled “getColorScheme()”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.
Returns
Section titled “Returns”Readonly<ThemeColorScheme>
getCustomColors()
Section titled “getCustomColors()”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.
Returns
Section titled “Returns”readonly ThemeCustomColor[]
getMajorFont()
Section titled “getMajorFont()”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.
Returns
Section titled “Returns”Readonly<ThemeFontCollection>
getMinorFont()
Section titled “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.
Returns
Section titled “Returns”Readonly<ThemeFontCollection>
removeCustomColor()
Section titled “removeCustomColor()”removeCustomColor(index): void;Removes a custom colour from the current theme by its index.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Throws
Section titled “Throws”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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Example
Section titled “Example”// Copy the theme from another workbook.workbook.theme.set(otherWorkbook.theme.get());setColorScheme()
Section titled “setColorScheme()”setColorScheme(scheme): void;Sets the current theme’s colour scheme.
Parameters
Section titled “Parameters”scheme
Section titled “scheme”Returns
Section titled “Returns”void
setMajorFont()
Section titled “setMajorFont()”setMajorFont(font): void;Sets the current theme’s major font collection.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
setMinorFont()
Section titled “setMinorFont()”setMinorFont(font): void;Sets the current theme’s minor font collection.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void