Document Solutions for Excel, Java Edition | Document Solutions
Features / Theme
In This Topic
    Theme
    In This Topic

    DsExcel Java enables users to choose from a set of built-in themes in order to enhance the overall appearance of the workbook. Also, it provides users with the ability to add and apply custom themes for configuring a workbook as per their choice.

    When a theme is modified, it impacts all the areas including the theme fonts, theme colors, range, chart titles etc. For example : if you apply a built-in or a custom theme to your workbook, it is possible that the color of the range as well as the font will also be modified based on the customized theme. The default theme of a workbook is the standard Office theme. The current theme of a workbook is represented by the ITheme interface.

    To change the current theme of the workbook, you need to first get the existing theme using the indexer notation of the Themes class.

    Refer to the following tasks to apply theme in your workbook:

    Apply built-in theme to the workbook

    To maintain consistency in the appearance across all the worksheets in the workbook, DsExcel Java enables users to add and apply theme from a set of built-in themes.

    In order to apply a built-in theme to your workbook, refer to the following example code.

    Java
    Copy Code
    // Change workbook's theme to Berlin
    workbook.setTheme(Themes.GetBerlin());

    Add a custom theme and set to workbook

    The Theme class can be used to add a custom theme to a workbook. After adding the custom theme, users can apply it to the workbook.

    In order to add a custom theme and apply it to the workbook, refer to the following example code.

    Java
    Copy Code
    // Add Custom Theme
    theme.getThemeColorScheme().get(ThemeColor.Light1).setRGB(Color.GetAntiqueWhite());
    theme.getThemeColorScheme().get(ThemeColor.Accent1).setRGB(Color.GetAliceBlue());
    theme.getThemeFontScheme().getMajor().get(FontLanguageIndex.Latin).setName("Buxton Sketch");
    theme.getThemeFontScheme().getMinor().get(FontLanguageIndex.Latin).setName("Segoe UI");
            
    // Apply Custom Theme
    workbook.setTheme(theme);