Spread Windows Forms 18
Spread Windows Forms 18 Product Documentation / Developer's Guide / Customizing the Sheet Appearance / Applying Theme to Customize the Appearance
In This Topic
    Applying Theme to Customize the Appearance
    In This Topic

    You can now easily modify the look & feel of your workbook using the provided themes. Spread themes include options to set the theme color, theme fonts, and theme effects. You can also customize these individual elements and manage overall appearance of the workbook. The tasks that relate to setting the appearance of the workbook include:

    Spread themes are shared across all Spread components to provide a uniform look.  In case a theme is not specified, default theme settings of are applied to the workbook. 

    Applying a New Theme

    Use the following code to apply any theme to the workbook to modify the apperance.

    C#
    Copy Code
    // To apply a new theme.
    var fileName = @"C:\Program Files\Microsoft Office\root\Document Themes 16\Gallery.thmx";
    fpSpread1.AsWorkbook().ApplyTheme(fileName);
    fpSpread2.AsWorkbook().ApplyTheme(fpSpread1.AsWorkbook().Theme);
    
    VB
    Copy Code
    ' To apply a new theme.
    Dim fileName As var =  "C:\Program Files\Microsoft Office\root\Document Themes 16\Gallery.thmx"
    fpSpread1.AsWorkbook().ApplyTheme(fileName)
    fpSpread2.AsWorkbook().ApplyTheme(fpSpread1.AsWorkbook().Theme)
    

    Spread provides a number of built-in themes as well. To apply a built-in theme to the workbook, use the BuiltInThemes enumeration option from GrapeCity.Core namespace as shown below.

    Copy Code
    fpSpread1.AsWorkbook().Theme = Theme.GetTheme(BuiltInThemes.Facet);
    

    Using Spread Designer, you can also apply your desired built-in themes. For more information, refer to Applying and Customizing Themes.

    Customizing the Theme Fonts

    Theme fonts contain a heading font and a body text font. You can change both of these fonts to create your own set of theme fonts. Refer to the following code snippet to customize the font scheme of your workbook.

    C#
    Copy Code
    // To customize theme fonts.
    string fileName = @"C:\Program Files\Microsoft Office\root\Document Themes 16\Theme Fonts\Century Gothic.xml";
    fpSpread1.AsWorkbook().Theme.FontScheme.Load(fileName);
    fpSpread2.AsWorkbook().Theme.FontScheme.Load(fileName);
    
    VB
    Copy Code
    ' To customize theme fonts.
    Dim fileName As String =  "C:\Program Files\Microsoft Office\root\Document Themes 16\Theme Fonts\Century Gothic.xml"
    fpSpread1.AsWorkbook().Theme.FontScheme.Load(fileName)
    fpSpread2.AsWorkbook().Theme.FontScheme.Load(fileName)
    

    Customizing the Theme Colors

    Refer to the following code snippet to customize the theme colors of your workbook.

    C#
    Copy Code
    // To customize theme colors.
    string fileName = @"C:\Program Files\Microsoft Office\root\Document Themes 16\Theme Colors\Yellow Orange.xml";
    fpSpread1.AsWorkbook().Theme.ColorScheme.Load(fileName);
    fpSpread2.AsWorkbook().Theme.ColorScheme.Load(fileName);
    
    VB
    Copy Code
    ' To customize theme colors.
    Dim fileName As String =  "C:\Program Files\Microsoft Office\root\Document Themes 16\Theme Colors\Yellow Orange.xml"
    fpSpread1.AsWorkbook().Theme.ColorScheme.Load(fileName)
    fpSpread2.AsWorkbook().Theme.ColorScheme.Load(fileName)
    

    Removing a Theme

    Refer to the following code snippet to remove the currently applied theme from your workbook and change it back to the default theme.

    C#
    Copy Code
    //To remove a theme
    fpSpread1.AsWorkbook().ApplyTheme("");
    fpSpread2.AsWorkbook().ApplyTheme("");
    
    VB
    Copy Code
    ' To remove a theme
    fpSpread1.AsWorkbook().ApplyTheme("")
    fpSpread2.AsWorkbook().ApplyTheme("")
    
    See Also