[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(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
包含主题信息。

Theme 描述工作簿主题,包括主题名称、是否为内置主题,以及关联的 IThemeColorScheme 和 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)
      使用指定的主题名称初始化 Theme 类的新实例。

      此构造函数调用 Theme(String,ITheme),并为基主题传入 null。如果未指定基主题,则使用 Office 主题作为起点。

      
       Theme theme = new Theme("Custom Theme");
       theme.getThemeColorScheme().get(ThemeColor.Accent1).setRGB(Color.GetBlue());
       workbook.setTheme(theme);
       
      Parameters:
      themeName - 主题名称。不能为 null、空或忽略大小写后等于内置主题名称。
      Throws:
      IllegalArgumentException - 如果 themeName 为 null、空或匹配内置主题名称。
    • Theme

      public Theme(String themeName, ITheme baseTheme)
      使用指定的主题名称和基主题初始化 Theme 类的新实例。

      通过复制指定基 ITheme 的设置来创建自定义主题。如果 baseTheme 为 null,则从 Office 主题初始化新主题。

      主题名称必须唯一,且不能为空或匹配内置主题名称。

      
       Theme theme = new Theme("CustomTheme", Themes.GetBerlin());
       theme.getThemeColorScheme().get(ThemeColor.Accent1).setRGB(Color.GetBlue());
       workbook.setTheme(theme);
       
      Parameters:
      themeName - 主题名称。不能为 null、空或内置主题名称。
      baseTheme - 要从中初始化的基主题。如果为 null,则使用 Office 主题。
      Throws:
      IllegalArgumentException - 如果 themeName 为 null、空或匹配内置主题名称。
  • Method Details

    • getName

      public final String getName()
      获取主题的名称。

      返回的名称标识当前主题,可用于通过 Themes.get(String) 查找主题。

      
       ITheme theme = Themes.GetBerlin();
       String name = theme.getName();
       
      Specified by:
      getName in interface ITheme
      Returns:
      主题的名称。
    • isBuiltIn

      public final boolean isBuiltIn()
      获取主题是否为内置主题。

      内置主题是由 Themes实用方法返回的预定义主题。以编程方式创建的自定义主题返回 false。

      
       ITheme theme = Themes.GetBerlin();
       boolean builtIn = theme.isBuiltIn();
       
      Specified by:
      isBuiltIn in interface ITheme
      Returns:
      如果主题是内置主题,则为 true;否则为 false。
    • getThemeColorScheme

      public final IThemeColorScheme getThemeColorScheme()
      获取主题内的颜色方案。

      表示主题内的颜色方案,并通过 ThemeColor 提供对主题颜色的访问。

      
       ITheme theme = workbook.getTheme();
       IThemeColorScheme colorScheme = theme.getThemeColorScheme();
       IThemeColor accent1 = colorScheme.get(ThemeColor.Accent1);
       
      Specified by:
      getThemeColorScheme in interface ITheme
      Returns:
      主题内的颜色方案。
    • getThemeFontScheme

      public final IThemeFontScheme getThemeFontScheme()
      获取主题内的字体方案。

      表示主题字体方案,并通过 IThemeFontScheme.getMajor() 和IThemeFontScheme.getMinor() 提供对主要和次要主题字体集合的访问。

      
       ITheme theme = Themes.GetBerlin();
       IThemeFontScheme fontScheme = theme.getThemeFontScheme();
       IThemeFonts majorFonts = fontScheme.getMajor();
       
      Specified by:
      getThemeFontScheme in interface ITheme
      Returns:
      主题内的字体方案。