[]
        
(Showing Draft Content)

Theme

Class Theme

java.lang.Object
com.grapecity.documents.excel.Theme
All Implemented Interfaces:
ITheme

public class Theme extends Object implements ITheme
Contains the theme information.

A Theme describes a workbook theme, including its name, whether it is built in, and the associated IThemeColorScheme and IThemeFontScheme.


 ITheme theme = new Theme("Custom Theme", Themes.GetBerlin());
 String name = theme.getName();
 boolean builtIn = theme.isBuiltIn();
 IThemeColorScheme colorScheme = theme.getThemeColorScheme();
 IThemeFontScheme fontScheme = theme.getThemeFontScheme();
 
  • Constructor Details

    • Theme

      public Theme(String themeName)
      Initializes a new instance of the Theme class with the specified theme name.

      This constructor calls Theme(String,ITheme) with null for the base theme. If no base theme is specified, the Office theme is used as the starting point.

      
       Theme theme = new Theme("Custom Theme");
       theme.getThemeColorScheme().get(ThemeColor.Accent1).setRGB(Color.GetBlue());
       workbook.setTheme(theme);
       
      Parameters:
      themeName - The name of the theme. Must not be null, empty, or equal to a built-in theme name ignoring case.
      Throws:
      IllegalArgumentException - if themeName is null, empty, or matches a built-in theme name.
    • Theme

      public Theme(String themeName, ITheme baseTheme)
      Initializes a new instance of the Theme class with the specified theme name and base theme.

      Creates a custom theme by copying settings from the specified base ITheme. If baseTheme is null, the new theme is initialized from the Office theme.

      The theme name must be unique and must not be empty or match a built-in theme name.

      
       Theme theme = new Theme("CustomTheme", Themes.GetBerlin());
       theme.getThemeColorScheme().get(ThemeColor.Accent1).setRGB(Color.GetBlue());
       workbook.setTheme(theme);
       
      Parameters:
      themeName - The name of the theme. Must not be null, empty, or the name of a built-in theme.
      baseTheme - The base theme to initialize from. If null, the Office theme is used.
      Throws:
      IllegalArgumentException - if themeName is null, empty, or matches a built-in theme name.
  • Method Details

    • getName

      public final String getName()
      Gets the name of the theme.

      The returned name identifies the current theme and can be used to look up a theme from Themes.get(String).

      
       ITheme theme = Themes.GetBerlin();
       String name = theme.getName();
       
      Specified by:
      getName in interface ITheme
      Returns:
      The name of the theme.
    • isBuiltIn

      public final boolean isBuiltIn()
      Gets whether the theme is a built-in theme.

      Built-in themes are the predefined themes returned by the Themes utility methods. Custom themes created programmatically return false.

      
       ITheme theme = Themes.GetBerlin();
       boolean builtIn = theme.isBuiltIn();
       
      Specified by:
      isBuiltIn in interface ITheme
      Returns:
      true if the theme is a built-in theme; otherwise, false.
    • getThemeColorScheme

      public final IThemeColorScheme getThemeColorScheme()
      Gets the color scheme within the theme.

      Represents a color scheme within the theme and provides access to the theme colors by ThemeColor.

      
       ITheme theme = workbook.getTheme();
       IThemeColorScheme colorScheme = theme.getThemeColorScheme();
       IThemeColor accent1 = colorScheme.get(ThemeColor.Accent1);
       
      Specified by:
      getThemeColorScheme in interface ITheme
      Returns:
      The color scheme within the theme.
    • getThemeFontScheme

      public final IThemeFontScheme getThemeFontScheme()
      Gets the font scheme within the theme.

      Represents the theme font scheme and provides access to the major and minor theme font collections through IThemeFontScheme.getMajor() and IThemeFontScheme.getMinor().

      
       ITheme theme = Themes.GetBerlin();
       IThemeFontScheme fontScheme = theme.getThemeFontScheme();
       IThemeFonts majorFonts = fontScheme.getMajor();
       
      Specified by:
      getThemeFontScheme in interface ITheme
      Returns:
      The font scheme within the theme.