Excel Themes and Colors

How to Apply and Create Color Scheme in Excel

Document themes make it easy to coordinate colors, fonts, and graphic formatting effects of Excel documents and update them quickly. Themes provide a unified look with named styles, graphical effects and other objects used in a workbook. For example, the Accent1 style, for example, looks different in the Office and the Apex themes. Often, you apply a document theme and then amend it to how you want it.

How to Apply a Color Scheme in Excel

  1. Open Excel and go to the “Page Layout” tab in the Excel ribbon.
  2. Click on the “Colors” button in the “Themes” section.
  3. Choose a color palette that matches your requirements or hover over a scheme to see a live preview.

How to Create a Custom Color Scheme in Excel

You can create your own color set to give your document a fresh, unique look or comply with your organization’s brand standards.

  1. Open Excel and go to the “Page Layout” tab in the Excel ribbon.

  2. Click on the “Colors” button in the “Themes” section.

  3. Click “Customize Colors…” button.

  4. In the “Create New Theme Colors” dialog box, you can select colors for each element by clicking on the color dropdowns next to them. You can choose colors from the palette or define custom colors using the “More Colors” option.

  5. After selecting all the desired colors, provide a name for your custom color scheme in the “Name” field.

  6. Click on the “Save” button to save your custom color scheme. Your custom color scheme will now be available in the “Colors” drop-down menu for future use.

How to Create and Apply Color Scheme in Aspose.Cells for Python via .NET

Aspose.Cells for Python via .NET provides features for customizing themes and colors.

How to Create Custom Color Theme in Aspose.Cells for Python via .NET

If theme colors are used in the file, we don’t need to modify each cell individually, we just need to modify the colors in the theme.

The following example shows how to apply custom themes with your desired colors. We use a sample template file manually created in Microsoft Excel 2007.

The following example loads a template XLSX file, defines colors for different theme color types, applies the custom colors and saves the excel file.

from aspose.cells import Workbook,License,PdfSaveOptions, LoadOptions, LoadFormat, LoadFilter, LoadDataFilterOptions, PasteOptions,PasteType
from aspose.pydrawing import Color
# For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Instantiate Workbook object.
# Open an exiting excel file.
workbook = Workbook(dataDir + "book1.xlsx")
# Define Color array (of 12 colors) for Theme.
colors = []
colors.append(Color.from_argb(255, 250, 235, 215)) # Background1
colors.append(Color.from_argb(255, 165, 42, 42)) # Text1
colors.append(Color.from_argb(255, 240, 248, 255)) # Background2
colors.append(Color.from_argb(255, 255, 255, 0)) # Text2
colors.append(Color.from_argb(255, 154, 205, 50)) # Accent1
colors.append(Color.from_argb(255, 255, 0, 0)) # Accent2
colors.append(Color.from_argb(255, 255, 192, 203)) # Accent3
colors.append(Color.from_argb(255, 128, 0, 128)) # Accent4
colors.append(Color.from_argb(255, 152, 251, 152)) # Accent5
colors.append(Color.from_argb(255, 255, 165, 0)) # Accent6
colors.append(Color.from_argb(255, 0, 128, 0)) # Hyperlink
colors.append(Color.from_argb(255, 128, 128, 128)) # Followed Hyperlink
# Set the custom theme with specified colors.
workbook.custom_theme("CustomeTheme1", colors)
# Save as the excel file.
workbook.save(dataDir + "output.out.xlsx")

How to Apply Theme Colors in Aspose.Cells for Python via .NET

The following example applies a cell’s foreground and font colors based on the default theme (of the workbook) color types. It also saves the excel file to disk.

from aspose.cells import BackgroundType, ThemeColor, ThemeColorType, Workbook
from os import os, path
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Create directory if it is not already present.
IsExists = path.isdir(dataDir)
if notIsExists:
os.makedirs(dataDir)
# Instantiate a Workbook.
workbook = Workbook()
# Get cells collection in the first (default) worksheet.
cells = workbook.worksheets[0].cells
# Get the D3 cell.
c = cells.get("D3")
# Get the style of the cell.
s = c.get_style()
# Set foreground color for the cell from the default theme Accent2 color.
s.foreground_theme_color = ThemeColor(ThemeColorType.ACCENT2, 0.5)
# Set the pattern type.
s.pattern = BackgroundType.SOLID
# Get the font for the style.
f = s.font
# Set the theme color.
f.theme_color = ThemeColor(ThemeColorType.ACCENT4, 0.1)
# Apply style.
c.set_style(s)
# Put a value.
c.put_value("Testing1")
# Save the excel file.
workbook.save(dataDir + "output.out.xlsx")

How to Get and Set Theme Colors in Aspose.Cells for Python via .NET

Below are a few methods and properties that implement theme colors.

The following example shows how to get and set theme colors.

The following example uses a template XLSX file, gets the colors for different theme color types, changes the colors and saves the Microsoft Excel file.

from aspose.cells import ThemeColorType, Workbook
from aspose.pydrawing import Color
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Instantiate Workbook object.
# Open an exiting excel file.
workbook = Workbook(dataDir + "book1.xlsx")
# Get the Background1 theme color.
c = workbook.get_theme_color(ThemeColorType.BACKGROUND1)
# Print the color.
print("theme color Background1: " + str(c))
# Get the Accent2 theme color.
c = workbook.get_theme_color(ThemeColorType.ACCENT2)
# Print the color.
print("theme color Accent2: " + str(c))
# Change the Background1 theme color.
workbook.set_theme_color(ThemeColorType.BACKGROUND1, Color.red)
# Get the updated Background1 theme color.
c = workbook.get_theme_color(ThemeColorType.BACKGROUND1)
# Print the updated color for confirmation.
print("theme color Background1 changed to: " + str(c))
# Change the Accent2 theme color.
workbook.set_theme_color(ThemeColorType.ACCENT2, Color.blue)
# Get the updated Accent2 theme color.
c = workbook.get_theme_color(ThemeColorType.ACCENT2)
# Print the updated color for confirmation.
print("theme color Accent2 changed to: " + str(c))
# Save the updated file.
workbook.save(dataDir + "output.out.xlsx")

Advance topics